vendredi 27 février 2015

PHP MVC Model with a method to fetch all of the model from database


I have a crazy question, consider I'm developing a blog website, There is two model named Post and Comment, now I wanna add a method to fetch all comments from database, which model should I choose to add this method to? Post or Comment.


Approach 1:



$post= new Post();
$post->setID($id);
$r = $post->loadAllComments();


Approach 2:



$r = Comment::loadAllComments($post_id);




Aucun commentaire:

Enregistrer un commentaire