简体   繁体   English

如何在INN中使用逗号分隔的字符串在cakePHP中查找?

[英]How to find in cakePHP using IN with comma separated strings.?

I am doing a code where I have to find something where a bunch of strings are here. 我正在做一个代码,我必须在这里找到一堆字符串。 and put there something above code. 并在代码上方放置一些内容。

$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 ) ));

but empty array returned... can you help me out? 但是返回空数组...您能帮帮我吗?

That's not even valid PHP code. 那甚至不是有效的PHP代码。 Just pass an array to conditions, ant it will create IN query: 只需将数组传递给条件,ant就会创建IN查询:

$status = array("free","busy");
$this->Driver->find ( 'all', 
  array( 
    'conditions' => array( 
      'Driver.work_status' => $status 
    )
  )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM