optimized query for getLastNumberFor function

This commit is contained in:
Robin Krahnen 2018-04-04 23:50:19 +02:00
parent 8fa1e1089e
commit da9d014c9d

View file

@ -112,9 +112,9 @@ class SequenceGenerator
$em = $this->entityManager; $em = $this->entityManager;
return $em->getConnection()->executeQuery( return $em->getConnection()->executeQuery(
'SELECT MAX(number) AS count FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type=:type', 'SELECT MAX(number) FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type = :type',
['type' => $this->inferTypeFromSource($type)] ['type' => $this->inferTypeFromSource($type)]
)->fetchAll()[0]['count']; )->fetchAll(\PDO::FETCH_COLUMN)[0];
} }
/** /**