$users->load()
maps to one db row at a time.
What you need is an array containing the mappers for every row, so use $users->find()
instead:
$users = new \models\User;
$f3->set('users',$users->find());
Вопрос
I am using fatfree framework with the Cortex ORM plugin, and I am trying to simply query the db and display the resulting rows within my template, so I tried:
In my controller:
$users = new \models\User;
$users->load();
$f3->set('users',$users);
/*while(!$users->dry()){
echo '<br/>'.$users->id;
$users->next();
}*/
echo \Template::instance()->render('pages/User/list.htm','text/html');
And in my template:
<repeat group="{{@users}}" value="{{@v}}">
<div>{{@v.id}}</div>
</repeat>
But the template stays blank. In the controller however, if I uncomment the while
block, then I do get the expected results, but how do I get it in my template?
Also if I remove the quotes and try group={{@users}}
, I get instance of class cannot be converted to string
error. So how do I loop through the results from within my template?
Решение
$users->load()
maps to one db row at a time.
What you need is an array containing the mappers for every row, so use $users->find()
instead:
$users = new \models\User;
$f3->set('users',$users->find());