如何在cakephp中编写SQL查询? [英] how to write SQL Query in cakephp?

查看:399
本文介绍了如何在cakephp中编写SQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select campaign,lead_status,COUNT(id)
from buyers 
where lead_status IN('Very Hot','Hot', 'Warm', 'Cold', 'Not Contacted') 
    and campaign IN('stage1','stage2','stage3','stage4') and created_on >='2012-10-01' 
    and is_put_for_exchange='0' and transaction_type='First Sale' 
    and propertytype='Residential' 
group by campaign,lead_status 
ORDER BY campaign asc, field(lead_status,'Very Hot','Hot', 'Warm', 'Cold', 'Not Contacted')

convert in cakephp语法plz It Argent

您可以通过执行

convert in cakephp Syntax plz It Argent?

推荐答案

cakephp.org/2.0/en/models/retrieving-your-data.html\">文档

You can modify your raw SQL into CakePHP format by going through the documentation.

或出于任何原因,您不能/不会,那么可以使用原始SQL查询,如下所示:

Or for any reason you cannot / will not, then you can use the raw SQL query as follows:

在控制器中:

$this->ModelName->query('SELECT * FROM table');

$this->query('SELECT * FROM table');

文档 query()

这篇关于如何在cakephp中编写SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆