Adde more BC compatibility in setParameters.
This commit is contained in:
parent
b3e7493278
commit
161ae31a7e
2 changed files with 18 additions and 1 deletions
|
@ -186,8 +186,17 @@ abstract class AbstractQuery
|
||||||
*/
|
*/
|
||||||
public function setParameters($parameters)
|
public function setParameters($parameters)
|
||||||
{
|
{
|
||||||
|
// BC compatibility with 2.3-
|
||||||
if (is_array($parameters)) {
|
if (is_array($parameters)) {
|
||||||
$parameters = new ArrayCollection($parameters);
|
$parameterCollection = new ArrayCollection();
|
||||||
|
|
||||||
|
foreach ($parameters as $key => $value) {
|
||||||
|
$parameter = new Query\Parameter($key, $value);
|
||||||
|
|
||||||
|
$parameterCollection->add($parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$parameters = $parameterCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
|
|
|
@ -165,6 +165,14 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
$users = $q->getResult();
|
$users = $q->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetParametersBackwardsCompatible()
|
||||||
|
{
|
||||||
|
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2');
|
||||||
|
$q->setParameters(array(1 => 'jwage', 2 => 'active'));
|
||||||
|
|
||||||
|
$users = $q->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-1070
|
* @group DDC-1070
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue