. */ namespace Doctrine\ORM\Internal\Hydration; use Doctrine\ORM\NoResultException; use Doctrine\ORM\NonUniqueResultException; /** * Hydrator that hydrates a single scalar value from the result set. * * @since 2.0 * @author Roman Borschel * @author Guilherme Blanco */ class SingleScalarHydrator extends AbstractHydrator { /** * {@inheritdoc} */ protected function hydrateAllData() { $data = $this->_stmt->fetchAll(\PDO::FETCH_ASSOC); $numRows = count($data); if ($numRows === 0) { throw new NoResultException(); } if ($numRows > 1 || count($data[key($data)]) > 1) { throw new NonUniqueResultException(); } $cache = array(); $result = $this->gatherScalarRowData($data[key($data)], $cache); return array_shift($result); } }