Welcome Guest, Not a member yet? Register   Sign In
Best practice selecting data from related models
#2

I agree with your intuition that person should not provide or manage comments. The comments model in both cases would be your primary domain of interest. If you are being terribly oop then your $this->comments->get_latest() would return a list of comment objects, each one encapsulating its author. If you want to display the author you might say: (for each comment to be displayed) $author = $comment->author(); echo $author->nick_name(). Or bending the law of demeter (foreach comment) $comment->author()->nick_name(). Then you can decide in your view whether to display the person's first and last name or nick_name, or status_level, etc. But if you are dealing with tens of thousands (millions?) of comments you may say nuts to oop and have the get_latest() method return an array of the results of the join of comments and people tables where date greater than...
Reply


Messages In This Thread
RE: Best practice selecting data from related models - by Shawn - 11-21-2016, 05:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB