mysql - Cake php join query -
i have write join query in cake php 1.3.
$supportbooks=$this->supportbook->find('all',array('joins'=>array( array( 'table'=>'supportbookstatuses', 'alias'=>'supportstatus', 'conditions' =>array('supportstatus.unique_id=supportbook.`unique_key`') ) )),array('conditions'=>array('supportbook.user_id'=>$user_id)));
this return following query:
select `supportbook`.`id`, `supportbook`.`category`, `supportbook`.`user_id`, `supportbook`.`email`, `supportbook`.`subject`, `supportbook`.`message`, `supportbook`.`reply`, `supportbook`.`unique_key`, `supportbook`.`replied` `fl_supportbooks` `supportbook` join `fl_supportbookstatuses` `supportstatus` on (`supportstatus`.`unique_id`=`supportbook`.`unique_key`) 1 = 1
the clause not working. there should clause : supportbook.user_id=21 how add clause?
you have parentesis error. should be:
$supportbooks=$this->supportbook->find('all',array('joins'=>array( array( 'table'=>'supportbookstatuses', 'alias'=>'supportstatus', 'conditions' =>array('supportstatus.unique_id=supportbook.`unique_key`') ) ),'conditions'=>array('supportbook.user_id'=>$user_id)));
Comments
Post a Comment