diff --git a/src/Kdyby/Doctrine/EntityDao.php b/src/Kdyby/Doctrine/EntityDao.php index aacb94ca..d4ead157 100644 --- a/src/Kdyby/Doctrine/EntityDao.php +++ b/src/Kdyby/Doctrine/EntityDao.php @@ -215,7 +215,8 @@ public function findAssoc($criteria, $key = NULL) public function select($alias = NULL, $indexBy = NULL) { if ($alias === NULL) { - $alias = strtolower(substr($this->_entityName, strrpos($this->_entityName, '\\'), 1)); + $pos = strrpos($this->_entityName, '\\'); + $alias = strtolower(substr($this->_entityName, $pos === FALSE ? 0 : $pos + 1, 1)); } $selection = $this->getEntityManager()->createSelection(); diff --git a/tests/KdybyTests/Doctrine/EntityDao.phpt b/tests/KdybyTests/Doctrine/EntityDao.phpt index 36ac8f68..58708ed3 100644 --- a/tests/KdybyTests/Doctrine/EntityDao.phpt +++ b/tests/KdybyTests/Doctrine/EntityDao.phpt @@ -105,6 +105,16 @@ class EntityDaoTest extends ORMTestCase Assert::same('SELECT u FROM KdybyTests\Doctrine\CmsUser u INDEX BY u.id', $qb->getDQL()); } + + + public function testSelectWithoutParameters() + { + $users = $this->em->getDao('KdybyTests\Doctrine\CmsUser'); + $qb = $users->select(); + + Assert::same('SELECT c FROM KdybyTests\Doctrine\CmsUser c', $qb->getDQL()); + } + } \run(new EntityDaoTest());