I have 3 Models. Each one has a column that holds a DateTime called “created” After performing a find() on each model, I would like to combine the 3 lists and sort them according to this created date. Is there an easy way to do this in cakephp. Here is the code snippet where I use find() to query the database. I do this 3 times, once with each Model. Is there a way to combine and sort these as I have described?
$this->set('users',
$this->Account->find('all',
array('conditions'=>
array('OR'=>
array('Account.organization_name LIKE'=>'%'.$words.'%',
'Account.first_name LIKE'=>'%'.$words.'%',
'Account.last_name LIKE'=>'%'.$words.'%',
'Account.middle_name LIKE'=>'%'.$words.'%')))),
$this->paginate());
I do that by combining all the different models into one array and doing
Set::sorton that, like this:If you need to have a model name for the entities, you can do that for example like this: