使用此DQL时
$getImages = $em->createQuery('SELECT stuff
FROM MyBundle:MyModelClass
WHERE model.id NOT IN (:hide)')
->setParameter('hide', join(',', $hide), 'array');
生成的SQL将映射到:
SELECT stuff FROM mymodelclass WHERE model.id NOT IN ('1,2,3');
这显然是错误的,因为它应该是
SELECT stuff FROM mymodelclass WHERE model.id NOT IN (1,2,3);
因此查询已完成。如何告诉doctrine映射数组而不将其转义为字符串?
答案 0 :(得分:3)
查看manual
$stmt = $conn->executeQuery('SELECT * FROM articles WHERE id IN (?)',
array(array(1, 2, 3, 4, 5, 6)),
array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY)
);