In Cakephp 2's model updateAll, we were using arrays as conditions. But this doesn't work :
$data=array(12, 22, 44);
TableRegistry::get('Foobar')->updateAll(
array("checked" => 1),
array("user_id" => $data)
);
Is this not possible in Cakephp 3's updateAll ?
This works in cakephp 3:
$data=12;
TableRegistry::get('Foobar')->updateAll(
array("checked" => 1),
array("user_id" => $data)
);
Regarding to API docs, $conditions defined like this:
updateAll( array $fields , mixed $conditions )
array $fields
A hash of field => new value.
mixed $conditions
Conditions to be used, accepts anything Query::where() can take.
Edit:
In case of cake works well and I'm making a mistake. How can I understand the cause ? Because when condition is an integer, code works well.
Edit2: This also works well:
$data=array(12, 22, 44);
ConnectionManager::get('default')->query('UPDATE foobars SET checked=1
WHERE user_id IN ('.implode(",",$data).')')->execute();
$datawill be user input!