Sunday, March 29, 2009

Re: Paginate Find All Results

That should be:

$paginate = array(
'FeedContent' => array(
'conditions' => 'CONDITIONS',
'fields' => 'FIELDS'
)
);

I don't know about using a key like 'Feed.FeedContent' but if it works ...

But you said that you already had your global paginate array set up
fine, but you want it altered just for one method. In that case, you
just need to alter $this->paginate before calling $this->paginate()
(why are those named the same, anyway?)

function your_action()
{
$this->paginate['FeedContent']['order'] = ...
$this->paginate['FeedContent']['conditions'] = ...

Or use array_merge() if you need to change several things

On Sun, Mar 29, 2009 at 10:04 PM, timtrice <tim.trice@gmail.com> wrote:
>
> I did attempt that with something like:
>
>        $paginate = array(
>                'Feed.FeedContent',
>                array(
>                        'conditions' => 'CONDITIONS',
>                        'fields' => 'FIELDS'
>                )
>        );
>
> Obviously I had myc onditions and fields listed, but that generated an
> error as if it where trying to find a field named "conditions".
>
> On Mar 29, 8:50 pm, brian <bally.z...@gmail.com> wrote:
>> You can modify $paginate temporarily from within a method.
>>
>> On Sun, Mar 29, 2009 at 9:38 PM, timtrice <tim.tr...@gmail.com> wrote:
>>
>> > I have the following Find query to retrieve search results from my DB:
>>
>> >                        $this->set(
>> >                                'results',
>> >                                $this->Feed->FeedContent->find(
>> >                                        'all',
>> >                                        array(
>> >                                                'conditions' => 'MATCH( name, keywords, description, encoded )
>> > AGAINST ( \'' . $keyword . '\')',
>> >                                                'fields' => '*, MATCH( name, keywords, description, encoded )
>> > AGAINST( \'' . $keyword . '\' ) AS score '
>> >                                        )
>> >                                )
>> >                        );
>>
>> > I'd like to paginate the results but I absolutely cannot find a way
>> > without generating errors.  I can't alter my paginate array I
>> > immediately declared in my Controller because that array is also
>> > controlling other actions I have set up perfectly.  I also do not want
>> > to throw this code into another model as I see it as way too much
>> > hassle to relate that Controller to the ones I have set up now.
>>
>> > Does anyone know about where I can find what I need to get this query
>> > paginated?  I hate to have to write additional coding to do what
>> > hoepfully will be easier than it seems with Cake.
>>
>> > Thanks
> >
>

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