Yes , RWS - Bharat Maheriya is right.
If you are writing queries for joins in the fabulous framework like cakephp
then what is the need to us the framwork.
Cakephp has a good feature of associations so please use that to join the
tables.
You have to write custom queries only few times & it is negligible.
So my suggestion is dont break the rules of the framework.
On Mon, Jul 27, 2009 at 11:33 AM, RWS - Bharat Maheriya <
rws.bha...@gmail.com> wrote:
> Hello
>
> you can define model association between agent and device and perform find
> operation with condition agents.verified=1only..CakePHP association perfom
> internal joining and give you expected result. you can try out with this...
>
> Thanks
>
>
>
> On Wed, Jul 22, 2009 at 7:17 PM, mona wrote:
>
>>
>> How to write the folowing query in cakephp
>>
>> $sql = "select
>> devices.uid,devices.agent,devices.capabilities,devices.localcaps from
>> devices,agents where devices.uid = agents.uid and agents.verified=1
>> limit 100";
>>
>> Followin is my controller file
>>
>> class AgentsController extends AppController {
>>var $name = 'Agents';
>>var $helpers =
>> array('Html','Form','Xml','Text','Javascript','Ajax');
>>var $uses = array( 'Agent','Device');
>>var $components = array('RequestHandler');
>>
>>
>>function admin_exportDevice(){
>>$this->_adminOnly();
>>$export = trim($this->data['deviceExport']['export']);
>>if($export=='Full'){
>> $sql = "select
>> devices.uid,devices.agent,devices.capabilities,devices.localcaps from
>> devices,agents where devices.uid = agents.uid and agents.verified=1
>> limit 100";
>> $qry = mysql_query($sql);
>>$this->set('qry', $qry);
>>$this->set('filename', 'Full'.date("Ymd").'.xml');
>>$this->layout='ajax';
>>
>>$sql1 = "Update devices set export=1 where export=0";
>>$query = mysql_query($sql1);
>>}
>> else{
>> $sql = "select
>> devices.uid,devices.agent,devices.capabilities,devices.localcaps from
>> devices,agents where devices.uid = agents.uid and agents.verified=1
>> and devices.export=0 limit 2";
>>$qry = mysql_query($sql);
>>$this->set('qry', $qry);
>>$this->set('filename', 'Incremental'.date("Ymd").'.xml');
>>$this->layout='ajax';
>>$sql1 = "Update devices set export=1 where export=0";
>>$query = mysql_query($sql1);
>>
>> }
>>}
>> }
>>
>>
>
> >
>
--
Thanks & Regards,
Vijayk.
Co-founder (www.weboniselab.com)
"You Bring the Dreams, We'll Bring the Means"
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---