Please don't do that directly. SQL (even in a limited form) sprinkled throughout the app is never good.
I do think that is a neat solution. However, the right way to implement it would be to define a custom model method called 'findAllSliced()' or something similar, so you can change the behavior in the future without grepping and replacing sprinkles of code all over. -----Original Message----- From: grigri <[EMAIL PROTECTED]> Reply-To: [email protected] To: CakePHP <[email protected]> Subject: Re: complex findAll() Date: Fri, 20 Jun 2008 04:34:34 -0700 (PDT) How: $results = $this->User->find('all', array( 'order' => "(User.id>=$userId) DESC, User.id ASC" )); Why: For $userId = 3: 3, 4, 5 : (User.id>=$userId) is 1 1, 2 : (User.id>=$userId) is 0 So 3,4 and 5 are first (themselves ordered by ID so they appear in that order) Then 1, 2 (again, ordered internally) hth grigri On Jun 20, 9:55 am, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote: > On Fri, Jun 20, 2008 at 2:15 PM, Fahad <[EMAIL PROTECTED]> wrote: > > findAll(), the record with ID 1 and 2 will added after ID 5. > > > =============== > > output (starting from ID 2) > > 3, anthony > > 4, ben > > 5, jonathan > > 1, john > > 2, james > > =============== > > #1 use two queries and array_merge the results > > #2 Do a simple find all and use array_slice with array_merge > > HTH > Tarique > > -- > ============================================================= > Cheesecake-Photoblog:http://cheesecake-photoblog.org > PHP for E-Biz:http://sanisoft.com > ============================================================= ++ Beatport DIGITAL DOWNLOAD NETWORK™ Ian Zepp - Software Engineer, RHCE, ZCE, CMDEV www.beatport.com - Access the world of club music™ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
