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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -