В запросе cakephp 3 выдается ошибка при добавлении условия 'IN' в запросе содержимого.
$itemsquery = $Students->find('all');
$itemsquery->select(['Students.id']);
$itemsquery->matching('CategoriesStudents');
$itemsquery->contain([
'CategoriesStudents' => function ($q) use ($category_ids) {
return $q->where(['CategoriesStudents.category_id IN' => $category_ids]);
}
]);
// debug($itemsquery);
$items = $itemsquery->toArray();
Ошибка
Impossible to generate condition with empty list of values for field (`CategoriesStudents`.`category_id`)
Error: An Internal Error Has Occurred.
An Internal Server Error Occurred
Таблицы
- category_students
category_id, student_id
студенты
категория
$ массив category_ids
Array
(
[1] => 57
[2] => 60
[3] => 58
[4] => 13
[5] => 78
[6] => 56
[7] => 59
[8] => 79
[9] => 95
[10] => 94
[11] => 96
[12] => 93
[13] => 82
[14] => 23
[15] => 82
[16] => 14
[17] => 16
[18] => 101
[19] => 14
)
Пожалуйста, помогите