php - CakePHP join tables in find query -


i have workposition model. linked in database orders belongsto relationship. so, need find specific workpositions bz conditions related orders model. so, when use example suck kind of find:

$workpositions = $this->workposition->find('all', array(                 'conditions' => array(                         'order.type' => 'n'                 ) )); 

cakephp understand order.id notation. when i'm trying use joins tables:

$workpositions = $this->workposition->find('all', array(                 'conditions' => array(                         'order.type' => 'n'                 )                 'joins' => array(                         array('table' => 'ordergroups_orders',                             'alias' => 'ordergroupsorder',                             'type' => 'inner',                             'conditions' => array(                                     'order.id = ordergroupsorder.order_id',                                     'ordergroupsorder.ordergroup_id' => '3',                                                                 )                     )                        ))); 

it gives me error : column not found: 1054 unknown column 'order.id' in 'on clause'. doesn't understand order.id notation. can problem ?

i tried make :

$workpositions = $this->workposition->find('all', array(                 'conditions' => $conditions,                 'joins' => array(                     array('table' => 'orders',                         'alias' => 'orders',                         'type' => 'inner',                     ),                     array('table' => 'ordergroups_orders',                             'alias' => 'ordergroupsorder',                             'type' => 'inner',                             'conditions' => array(                                     'orders.id = ordergroupsorder.order_id',                                     'ordergroupsorder.ordergroup_id' => $ordergroup_ids,                                                                 )                     )            ))); 

but error column not found: 1054 unknown column 'array' in 'on clause'(array string conversion). doesn't undestand array of ids, while undestands without binding of order model, when find method sees order.

the join conditions must array value, not key => value.

try change line

'ordergroupsorder.ordergroup_id' => $ordergroup_ids,  

to

'ordergroupsorder.ordergroup_id = $ordergroup_ids', 

$ordergroup_ids array? try use single id.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -