CakePHP find contain having deep orders -


i have following models:

client hasmany loan loan belongsto book loan belongsto client book belongsto booktype 

and tables this:

clients { id, name, ... } loans { id, client_id, book_id } books { id, book_type_id } book_types { id, title } 

i find loans clients's id. tried:

$client = $this->client->find('first', array(     'conditions' => array(         'client.id' => $id     ),     'contain' => array(         'loan' => array(             'book' => array(                 'booktype' => array(                     'order' => 'sachtitel desc'                 )             )         )     ) )); 

this doesn't work expected. data isn't sorted wanted be.

what doing wrong?

edit: okay, seems, long using contain, can't use order, because cakephp generates multiple queries obtain data. order useless, because 1 row fetched queries generated cakephp. how use join, fetch data table?

define order while creating relationships. try this:

$this->book->bindmodel(array(     'belongsto' => array(        'booktype' => array('order' => 'sachtitel desc' ) )); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -