Skip to content

Instantly share code, notes, and snippets.

@sobstel
Created December 14, 2010 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobstel/740225 to your computer and use it in GitHub Desktop.
Save sobstel/740225 to your computer and use it in GitHub Desktop.
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