On Sun, Aug 16, 2009 at 9:21 PM, Dave Maharaj ::
WidePixels.com<[email protected]> wrote:
>
> Never seen this $this->paginate['Bookmark']['contain'] = before, the
> ['contain'] part I mean
>
>
> So I just use it like a normal find array?
>
> $this->paginate['Bookmark']['contain'] = array('Job' => array('fields' =>
> array(so on and on))),
>
> And
>
> $this->paginate['Bookmark']['conditions'] = array('Bookmark.user_id' =>
> $this->Auth->user('id')),

This is from a controller I'm working on right now.

public $paginate = array(
        'Download' => array(
                'fields' => array(
                        'Download.id',
                        'Download.path',
                        'COUNT(Download.id) AS count',
                        'Download.item_file_id'
                ),
                'limit' => 25,
                'order' => array('count' => 'DESC'),
                'group' => array('Download.path'),
                'contain' => array(
                        'ItemFile' => array(
                                'fields' => array(
                                        'ItemFile.id',
                                        'ItemFile.basename',
                                        'ItemFile.type',
                                        'ItemFile.item_id'
                                ),
                                'Item' => array(
                                        'fields' => array('Item.id', 
'Item.name'),
                                        'Thumbnail' => array(
                                                'fields' => array(
                                                        'Thumbnail.item_id',
                                                        'Thumbnail.basename',
                                                        'Thumbnail.directory',
                                                        'Thumbnail.width',
                                                        'Thumbnail.height'
                                                )
                                        )
                                )
                        )
                )       
        )
);

This is a bit more complex than usual because I'm using COUNT() and
GROUP, but it still shows the contain bit.

In a particular action, if I wanted to narrow that down, I'd do, eg.

$this->paginate['Download']['conditions'] = array(
        'Download.foo' => $foo
);

And so that condition will be effective for any paginate() calls
within this action only.

> Is there no easy way to paginate from an array? Use a normal find() and pass
> the result to paginate?

I'm not sure what you mean by "from an array". AFAIK, it's the *only*
way to set up the params. As for using a normal find(), that's pretty
much what the controller does in the end. That's why the array setup
for paginate() is pretty much the same as find().

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to