0

I want to find all entries in my database beginning with id X. The problem is, that i need to find them not just: id>=X but with a specific sortation (like "votes" or "created"). like that:

$this->find('all',array('conditions' => array('example'=>'example', 'FROM id' => X),'order' => 'created ASC');

So my wanted results are not ordered by id like 2,5,6,7 they can be mixed up.

An example is: My wanted id's are 4,1,5,9,2,10,12. I already have 4 and 1. So I want to receive next everything from 1 on (5,9,2,10,12 in this order).

Is this possible?

Edit: Cake Version 2.5.4

tobysas
  • 308
  • 5
  • 18
  • 2
    I think what you are looking is already available via `find('neighbors')` etc. PS: You should always mention the exact cakephp version you are using. – mark Jan 26 '15 at 14:46

1 Answers1

0

Your question isn't worded very clearly, but, if all you want is to match records with a specific set of ids, all you need to do is pass the condition as 'id' => array(5,9,2,10,12). If you want the results sorted both by your order clause as well as by id, the most intuitive way to do that would probably be by using 'group' => array('id') to get results sorted by date, but split into subarrays corresponding to each id.

T.J. Compton
  • 405
  • 2
  • 11
  • Thanks for your effort, but my Problem is, that i only have 1 id and i want to receive the next rows After that id. In this example lets say i have id 5 and now i want to receive 9,2,10,12 without knowing them before.. – tobysas Jan 28 '15 at 08:31