function DatabaseStatementPrefetch::fetchAllAssoc
Overrides DatabaseStatementInterface::fetchAllAssoc
File
-
includes/
database/ prefetch.inc, line 486
Class
- DatabaseStatementPrefetch
- An implementation of DatabaseStatementInterface that prefetches all data.
Code
public function fetchAllAssoc($key, $fetch_style = NULL) {
$this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
$result = array();
// Traverse the array as PHP would have done.
while (isset($this->currentRow)) {
// Grab the row in its raw PDO::FETCH_ASSOC format.
$row = $this->currentRow;
// Grab the row in the format specified above.
$result_row = $this->current();
$result[$this->currentRow[$key]] = $result_row;
$this->next();
}
// Reset the fetch parameters to the value stored using setFetchMode().
$this->fetchStyle = $this->defaultFetchStyle;
$this->fetchOptions = $this->defaultFetchOptions;
return $result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.