我想查询数据库
Plates.page_number => 1 OR Plates.page_number => Cover
我正在尝试使用以下代码,但是由于数组键重复,我没有得到想要的结果,如何在同一字段中搜索两个不同的值?
$query = $this->Ledgers->find('all', array(
'contain' => array(
'Plates' => [
'conditions' => [
'OR' => [
'Plates.plate_title' => 'Front Cover',
'Plates.page_number' => '1',
'Plates.page_number' => 'Cover' // Duplicate Array Key
]
]
], 'Plates.PlateImages', 'Tribes'
),
'conditions' => array(
'Ledgers.disabled' => 'n', 'Ledgers.id IN' => $ledgerIds
)
))->orderAsc('ledger_title');
答案 0 :(得分:1)
请尝试将条件包装在单独的数组中,例如:
'OR' => [
['Plates.page_number' => '1'],
['Plates.page_number' => 'cover'],
...
]
更多信息可以在CakePHP文档中找到: