如何在CakePHP中编写MySQL查询

时间:2012-08-16 13:32:22

标签: mysql cakephp cakephp-1.3

如何在cakephp中编写以下mysql查询:

  

SELECT * FROM table WHERE DATE BETWEEN' 2008-12-23' AND' 2008-12-25';

1 个答案:

答案 0 :(得分:3)

使用Cake的ORM,它看起来像这样(Model是模型的名称,通常是表名的单一化版本):

$this->Model->find('all', array('conditions' => array(
    'Model.date BETWEEN ? AND ?' => array('2008-12-23', '2008-12-25')));

点击此处了解更多详情: http://book.cakephp.org/2.0/en/models/retrieving-your-data.html