You are here

public function StatementBase::setFetchMode in Drupal driver for SQL Server and SQL Azure 8.2

Sets the default fetch mode for this statement.

See http://php.net/manual/pdo.constants.php for the definition of the constants used.

Parameters

$mode: One of the PDO::FETCH_* constants.

$a1: An option depending of the fetch mode specified by $mode:

  • for PDO::FETCH_COLUMN, the index of the column to fetch
  • for PDO::FETCH_CLASS, the name of the class to create
  • for PDO::FETCH_INTO, the object to add the data to

$a2: If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the constructor.

Overrides StatementInterface::setFetchMode

4 calls to StatementBase::setFetchMode()
StatementBase::execute in drivers/lib/Drupal/Driver/Database/sqlsrv/StatementBase.php
Executes a prepared statement
StatementBase::fetchAllAssoc in drivers/lib/Drupal/Driver/Database/sqlsrv/StatementBase.php
Returns the result set as an associative array keyed by the given field.
StatementBase::fetchAllKeyed in drivers/lib/Drupal/Driver/Database/sqlsrv/StatementBase.php
Returns the entire result set as a single associative array.
StatementBase::__construct in drivers/lib/Drupal/Driver/Database/sqlsrv/StatementBase.php

File

drivers/lib/Drupal/Driver/Database/sqlsrv/StatementBase.php, line 145
Contains \Drupal\Core\Database\Statement.

Class

StatementBase
Default implementation of StatementInterface.

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function setFetchMode($mode, $a1 = null, $a2 = []) {

  // Call \PDOStatement::setFetchMode to set fetch mode.
  // \PDOStatement is picky about the number of arguments in some cases so we
  // need to be pass the exact number of arguments we where given.
  switch (func_num_args()) {
    case 1:
      return parent::setFetchMode($mode);
    case 2:
      return parent::setFetchMode($mode, $a1);
    case 3:
    default:
      return parent::setFetchMode($mode, $a1, $a2);
  }
}