5

我发现我不能做类似下面的事情,注意' :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');
4

1 回答 1

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));
于 2011-09-18T15:54:50.447 回答