W3cubDocs

/Drupal 7

public function DatabaseStatementPrefetch::setFetchMode

public DatabaseStatementPrefetch::setFetchMode($fetchStyle, $a2 = NULL, $a3 = NULL)

See also

PDOStatement::setFetchMode()

File

includes/database/prefetch.inc, line 239
Database interface code for engines that need complete control over their result sets. For example, SQLite will prefix some column names by the name of the table. We post-process the data, by renaming the column names using the same convention as…

Class

DatabaseStatementPrefetch
An implementation of DatabaseStatementInterface that prefetches all data.

Code

public function setFetchMode($fetchStyle, $a2 = NULL, $a3 = NULL) {
  $this->defaultFetchStyle = $fetchStyle;
  switch ($fetchStyle) {
    case PDO::FETCH_CLASS:
      $this->defaultFetchOptions['class'] = $a2;
      if ($a3) {
        $this->defaultFetchOptions['constructor_args'] = $a3;
      }
      break;
    case PDO::FETCH_COLUMN:
      $this->defaultFetchOptions['column'] = $a2;
      break;
    case PDO::FETCH_INTO:
      $this->defaultFetchOptions['object'] = $a2;
      break;
  }

  // Set the values for the next fetch.
  $this->fetchStyle = $this->defaultFetchStyle;
  $this->fetchOptions = $this->defaultFetchOptions;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!database!prefetch.inc/function/DatabaseStatementPrefetch::setFetchMode/7.x