I ran in to a problem what i never experienced with fuelphp.
On the users profile page i allow other users to leave comments.
And when i use related comments limit
in my controller function its just ignored.
Code
public function action_view($id)
{
$user = Model_User::find($id, array(
'related' => array(
'comments' => array(
'order_by' => array(
array('id', 'DESC'),
),
),
),
'limit' => 5,
));
if(empty($user)):
Response::redirect(Uri::base() . "welcome/404");
endif;
$this->template->title = $user->username . "'s Profile | " . Config::get('site_name');
$this->template->content = View::forge('user/profile', array('user' => $user));
}
The order_by
works like a charm, but the limit doesnt, it still lists all the comments.
Tryed multiple variations got lot of different weird errors.
EDIT: I've found this part of the docs, it should help you: troubleshooting
Try to put the "limit" in the properties array: in the current position the "limit" limit the number of user, but you are retrieving a single user so it doesn't work.
Try with this:
$user = Model_User::find($id, array(
'related' => array(
'comments' => array(
'order_by' => array(
array('id', 'DESC'),
),
'limit' => 5,
),
),
));