public function Statement::execute

public Statement::execute($args = array(), $options = array())

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

core/lib/Drupal/Core/Database/Statement.php, line 42

Class

Statement
Default implementation of StatementInterface.

Namespace

Drupal\Core\Database

Code

public function execute($args = array(), $options = array()) {
  if (isset($options['fetch'])) {
    if (is_string($options['fetch'])) {
      // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties
      // are added to the object.
      $this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $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;
}

© 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/core!lib!Drupal!Core!Database!Statement.php/function/Statement::execute/8.1.x