sql - join 3 tables on cakephp -


i'm trying join 3 tables using cakephp don't understand why when execute query there result of main tables without attributes other 2 tables . php code :

$flightschedule = $this->flightschedules->find('all', array(     'join' => array(         array(            'table' => 'weeklyschedules',            'alias' => 'ws',            'type' => 'inner',            'conditions' => array(            'flightschedules.code = ws.flight_plan_code'         ),         array(            'table' => 'structures',            'alias' => 's',            'type' => 'left',            'conditions' => array(            'flightschedules.code = s.flight_plan_code',        )),     )),     'conditions' => array(         'flightschedules.plane_code' => 'xxx'      ), )); 

the result of flightschedules record without join of other tables . ideas how fix ?

use "fields" display data of associated table .

  $flightschedule = $this->flightschedules->find('all', array(             'join' => array(                 array(                    'table' => 'weeklyschedules',                    'alias' => 'ws',                    'type' => 'inner',                    'conditions' => array(                    'flightschedules.code = ws.flight_plan_code'                 ),                 array(                    'table' => 'structures',                    'alias' => 's',                    'type' => 'left',                    'conditions' => array(                    'flightschedules.code = s.flight_plan_code',                )),             )),             'conditions' => array(                 'flightschedules.plane_code' => 'xxx'              ),         'fields'=>'flightschedules.*,ws.*,s.*'          )); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -