Created
December 12, 2013 13:29
-
-
Save jacobsenj/7927932 to your computer and use it in GitHub Desktop.
Repository Method to get MAX + 1 of a number field within the entity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Application\Repository; | |
use Application\Entity\Name; | |
use Doctrine\ORM\EntityRepository; | |
class NameRepository | |
extends EntityRepository | |
{ | |
/** | |
* @return int | |
*/ | |
public function getNextNumber() | |
{ | |
return $this->getEntityManager()->createQuery('SELECT MAX(n.number) + 1 AS number FROM Application\Entity\Name n')->getSingleScalarResult(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment