[eluser]rei[/eluser]
I like the second one that follows strict model approach.
So if I wanted to get all the users, then get all the posts related to each user, then get the comments related to each post. I will do something like:
Code:
$u = new User();
$u->include_related('post', 'post');
$u->include_related('post/comment', 'comment');
$u->get();
so I can return the $u to the controller. Am I correct sir?
And by the way..
I tried this one:
Code:
$users = new User();
$users->include_related('post', 'name');
$users->get();
// print_r($users);
foreach ($users as $user)
{
echo $user->name;
echo $user->post_name;
echo '<br>';
echo '<br>';
}
It works perfect, but the name of the user keeps repeating. How can I only show the name of the user once? and then show all the posts that belongs to that user. Thanks in advance sir
And last question.
is it bad practice to make datamapper calls in the view like this one:
Code:
<?php foreach($student_list as $student): ?>
<?php $student->course->get()->order_by('name'); ?>
<?php endforeach; ?>