Created
March 18, 2015 17:55
-
-
Save billschaller/90e4b4d6414fbf2b0e68 to your computer and use it in GitHub Desktop.
fast array hydration for single entities, no associations, no type conversions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@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