where concat(`year`,'-',`month`) BETWEEN '2013-02' AND '2013-03';
如何在cake php的自定义查询分页中使用此查询,就像这样..
$conditions = array('concat('Payroll.year','-','Payroll.month') BETWEEN ? and ?' => array(2013-02, 2013-03));
$staff_list = $this->Payroll->find("all", array("fields" => array("Payroll.id", "Payroll.month", "Payroll.year"),"conditions"=>$conditions));
谢谢。
答案 0 :(得分:2)
var $virtualFields = array(
'payroll_date' => 'CONCAT(Payroll.year, " ", Payroll.month)'
);
并在控制器中:
$staff_list = $this->Payroll->find("all", array(
"fields" => array("Payroll.id", "Payroll.month", "Payroll.year"),
"conditions" => array('Payroll.payroll_date BETWEEN ? AND ?' => array('2013-02', '2013-03'))
));