Monday, June 4, 2012

Re: How to order paginated results for more than one order condition?

I had a similar issue 
and this solved it I dont know if this will work for you but it might put you on the right path 
try something like this 


$this->paginate = array(

      'order' => array('somefiled' => 'desc'),
        'group' => array('somefiled'), ('anotherfiled')')
  );

you might have to do a manual query and then paginate the query


 
On Monday, June 4, 2012 4:08:07 AM UTC-7, heohni wrote:
Hi,

When I perform a search for results I use this default oder condition:
$this->paginate['MyModel']['order'] = typeA ASC, typeB ASC;

Within my search form the user can also select to order by typeC asc or desc.

When the search is now performed the chosen condition "order by typeC asc" is overwriting all my previous set order conditions.
The maysql statement is ONLY ordering by typeC and doesn't also order for typeA and typeB anymore.

Is there a way how to handle various "order by" conditions depending on the performed search and their conditions?
Can I manually set the "order by" condition and avoid the magic of phpcake of overwriting it?

Please help me out!!

Thanks!!


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: