0

使用此 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);

所以查询是正确的。如何告诉教义映射数组而不将其转义为字符串?

4

1 回答 1

3

说明书

$stmt = $conn->executeQuery('SELECT * FROM articles WHERE id IN (?)', array(array(1, 2, 3, 4, 5, 6)), array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY) );

于 2012-02-18T11:07:43.123 回答