0

I would like to query the database for

Plates.page_number => 1 OR Plates.page_number => Cover

I am attempting to use the following code, but I am not getting the results I am looking for because of a duplicate array key, how can I search the same field for two different values?

   $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');
Jeffrey L. Roberts
  • 2,844
  • 5
  • 34
  • 69

1 Answers1

1

Please try wrapping your conditions in separate arrays, eg:

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

More info can be found in CakePHP docs:

Query Builder -> Advanced Conditions

Szymon
  • 1,385
  • 1
  • 8
  • 10