CakePHP v1.3.15中的多个OR条件

时间:2014-11-25 18:18:16

标签: php cakephp

我在cake php查询构建器中遇到OR条件问题。这将返回0结果。

$results = $this->paginate('Did', array('Did.ivr_id LIKE ' => $number . "%",'OR'=>array('Did.did LIKE ' => $number . "%")));
$result = $this->paginate = array(array('Did.did LIKE' => $number . "%"));
$this->set('dids', $results);

当我在简单列上应用条件时,它会给出准确的结果

$results = $this->paginate('Did', array('Did.ivr_id LIKE' => $number . "%"));
 $result = $this->paginate = array(array('Did.did LIKE' => $number . "%"));
    $this->set('dids', $results);

1 个答案:

答案 0 :(得分:1)

您需要在OR数组中放置您想要的所有条件。

$results = $this->paginate(
    'Did', 
    array(
        'OR'=>array(
             'Did.ivr_id LIKE ' => $number . "%", 
             'Did.did LIKE ' => $number . "%"
         )
    )
);