1
0
mirror of synced 2025-01-18 22:41:43 +03:00

DDC-233 - Fixed use of array_merge() because it re-assigns the numerical indexes from 0 on.

This commit is contained in:
beberlei 2010-01-06 14:21:17 +00:00
parent 375c470e93
commit 6e4e45e18e
2 changed files with 14 additions and 1 deletions

View File

@ -154,7 +154,7 @@ abstract class AbstractQuery
public function getParameters($params = array())
{
if ($params) {
return array_merge($this->_params, $params);
return ($this->_params + $params);
}
return $this->_params;
}

View File

@ -29,6 +29,19 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position
}
public function testGetParameters()
{
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
$this->assertEquals(array(1 => 42), $query->getParameters(array(1 => 42)));
}
public function testGetParameters_HasSomeAlready()
{
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
$query->setParameter(2, 84);
$this->assertEquals(array(2 => 84, 1 => 42), $query->getParameters(array(1 => 42)));
}
public function testSimpleQueries()
{
$user = new CmsUser;