public function Statement::execute

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Core/Database/Statement.php \Drupal\Core\Database\Statement::execute()
  2. 9.x drupal/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php \Drupal\Core\Database\Driver\sqlite\Statement::execute()

Executes a prepared statement

Parameters

$args: An array of values with as many elements as there are bound parameters in the SQL statement being executed.

$options: An array of options for this query.

Return value

TRUE on success, or FALSE on failure.

Overrides StatementInterface::execute

File

drupal/core/lib/Drupal/Core/Database/Statement.php, line 40
Definition of Drupal\Core\Database\StatementBase

Class

Statement
Default implementation of DatabaseStatementInterface.

Namespace

Drupal\Core\Database

Code

public function execute($args = array(), $options = array()) {
  if (isset($options['fetch'])) {
    if (is_string($options['fetch'])) {

      // Default to an object. Note: db fields will be added to the object
      // before the constructor is run. If you need to assign fields after
      // the constructor is run, see http://drupal.org/node/315092.
      $this
        ->setFetchMode(PDO::FETCH_CLASS, $options['fetch']);
    }
    else {
      $this
        ->setFetchMode($options['fetch']);
    }
  }
  $logger = $this->dbh
    ->getLogger();
  if (!empty($logger)) {
    $query_start = microtime(TRUE);
  }
  $return = parent::execute($args);
  if (!empty($logger)) {
    $query_end = microtime(TRUE);
    $logger
      ->log($this, $args, $query_end - $query_start);
  }
  return $return;
}