> How can I rewrite my function to do things like u suggested???
>
> On 2 Ott, 21:53, "Mariano C." <mariano.calan...@gmail.com> wrote:
>> my function that paginate is something like
>>
>> function ... paging()
>> {
>> $this->paginate = array(.....);
>> $books = $this->paginate('Book');
>> // this is where i can get the information printed in first post
>> $this->set(compact('books'));
>>
>> }
It's unclear to me which controller we're talking about. You mentioned
paginating books but also that what you're interested in is a
particular User's Books. Unless you mean that you want to paginate a
particular User's Books, maybe?
If you're fetching a single User and you'd like to see their Books in the data:
$data = $this->User->find(
'first',
array(
'conditions' => array(
'User.id' => $id
),
'fields' => array('...'),
'contain' => array(
'Book'
)
)
);
If you're paginating several Users and you'd like to include each of
their Book collections:
public $paginate = array(
'fields' => array('*'),
'limit' => 10,
'order' => array('User.surname' => 'ASC'),
'contain' => array(
'Book' => array(
'fields' => array(
'Book.id',
'Book.title'
),
'order' => array('Book.title' => 'ASC')
)
)
);
public function index()
{
$this->set(
'data'
$this->paginate()
);
}
If you're paginating Books and want to see theUsers who have each in
the collections:
public $paginate = array(
'fields' => array('*'),
'limit' => 10,
'order' => array('Book.title' => 'ASC'),
'contain' => array(
'User' => array(
'fields' => array(
'User.id',
'User.surname'
),
'order' => array('User.surname' => 'ASC')
)
)
);
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment