我正在对模型进行查找,如下所示,但是生成的 SQL 是错误的,因此我得到了不正确的结果。
$bookings = $this->Booking->find('all', array(
'conditions' => array(
'Booking.created BETWEEN ? AND ?' => array(
date('Y-m-d H:i:s', strtotime('-24 hours')),
date('Y-m-d H:i:s', strtotime('-12 hours'))
),
'OR' => array(
'Booking.payment_status' => 3,
'Booking.payment_status' => 2
)
)
));
此查找生成的 WHERE 条件是(如 cake debugkit 所示)
WHERE `Booking`.`created` BETWEEN '2013-03-27 11:01:57' AND '2013-03-27 23:01:57' AND `Booking`.`payment_status` = 2
我试图创造的条件是
WHERE `Booking`.`created` BETWEEN '2013-03-27 11:01:57' AND '2013-03-27 23:01:57' AND (`Booking`.`payment_status` = 2 OR `Booking`.`payment_status` = 3)
任何想法我在这里做错了什么。快速帮助将不胜感激。谢谢!