Cake 2.6 conditions WHERE IN?


#1

Hi,
Do you know some kind of trick for?
Simple code :
$arr = array(55, 77)
$conditions = [‘id IN’ => $arr];
$fields = [‘id’, ‘deleted’, ‘newsletter’];
$users = $this->User->find(‘all’, compact(‘conditions’, ‘fields’));

It works if $rr length more then one, and generates SQL error if $arr length equal one.
(SELECT User.id, User.deleted, User.newsletter FROM sp_test.xx_users AS User WHERE id IN = (55))
Do you know some kind of trick for tell Cake generate clausure WHERE IN (55) when $arr length = 1 ?
I two ideas , but it dislaike it.

  1. Add nonexisting array element. ( $arr(0, 55) ).
  2. if (count($arr) == 1) {$conditions = [ ‘id’ => $arr ]
    }else{[‘id IN’ => $arr] }

Thank you.