. */ namespace Doctrine\ORM\Id; use Doctrine\ORM\EntityManager; /** * Represents an ID generator that uses the database UUID expression * * @since 2.3 * @author Maarten de Keizer */ class UuidGenerator extends AbstractIdGenerator { /** * Generates an ID for the given entity. * * @param EntityManager $em The EntityManager to use. * @param object $entity * * @return string The generated value. * * @override */ public function generate(EntityManager $em, $entity) { $conn = $em->getConnection(); $sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression(); return $conn->query($sql)->fetchColumn(0); } }