我正在做一个代码,我必须找到一些字符串在这里的东西。把那些代码放在上面。
$status = "free","busy"
// In database there is work_status is saved either as free, busy, onduty.....
I have to find whether driver is free , busy. want to put an array into condition.
$this->Driver->find ( 'all', array( 'conditions' => array( 'Driver.work_status' => array( $driver_status ) ));
但是空数组返回了......你能帮帮我吗?
答案 0 :(得分:3)
这甚至都不是有效的PHP代码。只需将数组传递给条件,它就会创建IN查询:
$status = array("free","busy");
$this->Driver->find ( 'all',
array(
'conditions' => array(
'Driver.work_status' => $status
)
)
);