php - Doctrine DQL, using the IN statement with entities -


is in doctrine possible use in statement , pass list of entities parameter in statement?

for example, with following relation:

/**  * @var \doctrine\common\collections\collection  *  * @orm\onetomany(targetentity="calendar", mappedby="education", cascade={"persist"})  */ private $calendar; 

i query like:

 select p education p p.calendar in (:calendar) 

an :calendar parameter array of entities.

$query->setparameter('calendar', array($singleentity,$singleentity2)); 

but gives following error:

near 'calendar in (:calendar)': error: invalid pathexpression. statefieldpathexpression or singlevaluedassociationfield  

you can use full entities in statement , dql like

$query->select('p')   ->from('education', 'p')   ->where($query->expr()->in('p.calendar', ':values'))   ->setparameter('values',  array($singleentity,$singleentity2)); 

i have used before quite few times if recall correctly , worked. use join , attribute cerad suggested should work too.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -