当我运行createQueryBuilder Query时,将Array作为参数值传递,显示为数组undefined。
$list = array('13','197');
$queryBuilder = function($repo) use ($user) {
return $repo->createQueryBuilder('p')
->where('p.id IN (:stores)')
->setParameter('stores',$list);
->orderBy('p.name', 'ASC');
}
答案 0 :(得分:3)
您需要在lambda函数范围中包含$list
变量。为此,您需要在use
中提供此变量 - lambda函数定义的一部分:
$list = array('13','197');
$queryBuilder = function($repo) use ($user, $list) {
return $repo->createQueryBuilder('p')
->where('p.id IN (:stores)')
->setParameter('stores',$list);
->orderBy('p.name', 'ASC');
}