Pregunta

When using this DQL

$getImages = $em->createQuery('SELECT stuff
    FROM MyBundle:MyModelClass
    WHERE model.id NOT IN (:hide)')
->setParameter('hide', join(',', $hide), 'array');

The resulting SQL will be mapped to:

SELECT stuff FROM mymodelclass WHERE model.id NOT IN ('1,2,3');

Which is obviously wrong as it should be

SELECT stuff FROM mymodelclass WHERE model.id NOT IN (1,2,3);

So the query is fulfilled correclty. How can I tell doctrine to map the array without escaping it to a string?

¿Fue útil?

Solución

Look at 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) );

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top