CakePHP 3.x OR 在具有多个相同字段的查找条件中

CakePHP 3.x OR In Find Condition With Multiple Same Fields

我想查询数据库

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

请尝试将您的条件包装在单独的数组中,例如:

'OR' => [
    ['Plates.page_number' => '1'],
    ['Plates.page_number' => 'cover'],
    ...
]

可以在 CakePHP 文档中找到更多信息:

Query Builder -> Advanced Conditions