【发布时间】:2015-11-02 11:07:40
【问题描述】:
我正在使用此查询来获取匹配结果:
$result = $this->Customer->CustomersC->find('list', array(
'conditions' => array('CustomersC.company_id IN' => $companyIds),
'fields' => array('CustomersC.customer_id'),
));
如果$companyIds 有多个值,则查询完美。这是日志中打印的查询:
SELECT
CustomersC.customer_idFROMproject.customers_companiesASCustomersCWHERECustomersC.company_idIN (7, 8, 9, 11, 15)
但是,如果$companyIds 只有一个值,则会引发 SQL 异常。这是查询:
SELECT
CustomersC.customer_idFROMproject.customers_companiesASCustomersCWHERECustomersC.company_idIN = ('7')
请注意在 IN 之后添加的不必要的 =(equalTo 运算符)。
有人可以指出我处理这种情况的正确方向吗?
【问题讨论】:
标签: cakephp in-operator