mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1697: DQL Query with key=>value array in parameter #2137
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Mar 12, 2012).
Jira issue originally created by user waldo2188:
In he method "processParameterValue" in the class Doctrine\ORM\Query line 303, a "for" loop is use for construct the parameter query.
But if in the query parameter we pass a key=>value array, the method throw an error.
A little example :
$aId = array(0 => "Paris", 3 => "Canne", 9 => "St Julien");
$dql = $this->_em->createQueryBuilder();
$dql->select('c.ID')
->from('BOD\ModelBundle\Entity\City', 'c')
->where('c.IC IN (:cityIDs)')
->setParameter('cityIDs', $aId);
return $dql->getQuery()->execute();
The method "processParameterValue" throw an error because he don't found the index 1.
But if we replace the "for" loop by a foreach in Doctrine\ORM\Query::processParameterValue() :
foreach ($value as $keyValue => $oneValue) {
$paramValue = $this->processParameterValue($oneValue);
// TODO: What about Entities that have composite primary key?
$value[$keyValue] = is_array($paramValue) ? $paramValue[key($paramValue)] : $paramValue;
}
It work really fine.
I remain at your disposal for any further information.
Thanks for all!
@doctrinebot commented on GitHub (Mar 25, 2012):
Comment created by @FabioBatSilva:
Fixed by :
8a52e3033b@doctrinebot commented on GitHub (Mar 25, 2012):
Issue was closed with resolution "Fixed"