在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_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
)
请帮助