On Mar 23, 5:28 am, sebb86 <[email protected]> wrote:
> Thanks for your help but i still dont get it working. sorry for my bad
> knowledge.
Ha! No worries. I'm certainly no expert.
> In my addModel, i added this line: [code]var $actsAs =
> array('Containable');[/code]
>
> In my controller i tryed this to use contain with paginate:
> [code]
> $this->set('ports', $this->paginate('Port', array('fields' =>
> array('*'), 'contain' => array('PortUplink' =>
> array('HardwareUnit')))));
> [/code]
> But i get lots of errors...for example, 'fields' is unknown.
> Greetings.
I see the problem. You must set the pagination options in the class
var $paginate. The *method* paginate() takes different params:
http://api.cakephp.org/class/controller#method-Controllerpaginate
The 2nd param there is for conditions. So, with what you did 'fields'
was passed in the SQL query literally and the DB complained it didn't
know about that column.
Try this:
var $paginate = array(
'Port' => array(
'fields' => array('*'),
'limit' => some number here,
'order' => array('Port.some_field' => 'ASC'),
'contain' => array(
'PortUplink' => array(
'HardwareUnit'
)
)
)
);
Of course, you can leave out the 'order' option.
In the action:
$this->set(
'ports',
$this->paginate('Port')
);
Search for "you can define more than one set of pagination defaults"
on this page:
http://book.cakephp.org/view/165/Controller-Setup
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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
To unsubscribe from this group, send email to
cake-php+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.