Skip to content

Instantly share code, notes, and snippets.

@billschaller
Created March 18, 2015 17:55
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 billschaller/90e4b4d6414fbf2b0e68 to your computer and use it in GitHub Desktop.
Save billschaller/90e4b4d6414fbf2b0e68 to your computer and use it in GitHub Desktop.
fast array hydration for single entities, no associations, no type conversions
/**
* {@inheritdoc}
*/
protected function hydrateAllData()
{
$firstRowData = $this->_stmt->fetch(PDO::FETCH_ASSOC);
$headings = array_keys($firstRowData);
$fields = [];
foreach($headings as $idx => $column) {
$colInfo = $this->hydrateColumnInfo($column);
$fields[$idx] = $colInfo['fieldName'];
}
$rows = [];
$rows[] = array_combine($fields, array_values($firstRowData));
$rawRows = $this->_stmt->fetchAll(PDO::FETCH_NUM);
foreach ($rawRows as $row) {
$rows[] = array_combine($fields, $row);
}
return $rows;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment