Question

Lorsque vous utilisez ce DQL

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

Le SQL résultant sera mis en correspondance à:

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

Ce qui est évidemment faux car il doit être

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

Ainsi, la requête est remplie correclty. Comment puis-je dire à la doctrine de la carte du tableau sans échapper à une chaîne?

Était-ce utile?

La solution

Regardez manuel

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top