我发现我无法执行以下操作,请注意“:user
”使用了两次
$query = $em->createQuery('select p from Application\Models\Project p
WHERE p.owner = :user
OR :user MEMBER OF p.collaborators');
$query->setParameter('user', $user);
我收到错误“array_combine(): Both parameters should have an equal number of elements
”
我可以通过执行类似下面的操作来解决问题
$query = $em->createQuery('select p from Application\Models\Project p
WHERE p.owner = :user
OR :user1 MEMBER OF p.collaborators');
答案 0 :(得分:3)
如果您使用?X,您可以这样做。
$query = $em->createQuery('select p from Application\Models\Project p
WHERE p.owner = ?0
OR ?0 MEMBER OF p.collaborators');
$query->setParameters(array($user));