Instantly share code, notes, and snippets.

Embed
What would you like to do?
Doctrine_Hydrator_FlatArray
<?php
/**
* Doctrine::HYDRATE_SCALAR without component alias at the beginning.
* For key names it takes columns and aliases from SELECT statement.
* First column/alias from statement is used as key for whole row.
*/
class Doctrine_Hydrator_FlatArray extends Doctrine_Hydrator_ScalarDriver {
public function hydrateResultSet($stmt)
{
$cache = array();
$result = array();
while ($data = $stmt->fetch(Doctrine_Core::FETCH_ASSOC)) {
$row = $this->_gatherRowData($data, $cache, false);
$result[current($row)] = $row;
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment