1
0
mirror of synced 2025-01-17 22:11:41 +03:00

Merge pull request #86 from kwiateusz/findByOne-patch

Now findByOne really retrieve only one entity adding limit to query
This commit is contained in:
Guilherme Blanco 2011-07-21 10:01:21 -07:00
commit 01d6ec35c4
2 changed files with 4 additions and 3 deletions

View File

@ -178,7 +178,7 @@ class EntityRepository implements ObjectRepository
*/
public function findOneBy(array $criteria)
{
return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->load($criteria);
return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->load($criteria, null, null, array(), 0, 1);
}
/**

View File

@ -559,12 +559,13 @@ class BasicEntityPersister
* @param $assoc The association that connects the entity to load to another entity, if any.
* @param array $hints Hints for entity creation.
* @param int $lockMode
* @param int $limit Limit number of results
* @return object The loaded and managed entity instance or NULL if the entity can not be found.
* @todo Check identity map? loadById method? Try to guess whether $criteria is the id?
*/
public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0)
public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0, $limit = 0)
{
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode);
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode, $limit);
list($params, $types) = $this->expandParameters($criteria);
$stmt = $this->_conn->executeQuery($sql, $params, $types);