execute

  1. drupal
    1. drupal7
Versionen
drupal7 public DatabaseStatementPrefetch::execute($args = array(), $options = array())

Executes a prepared statement.

Übergabeparameter

$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.

Rückgabewert

TRUE on success, or FALSE on failure.

Verwandte Themen

Code

includes/database/prefetch.inc, line 145

<?php
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']);
    }
  }
  $this->dbh->lastStatement = $this;

  $logger = $this->dbh->getLogger();
  if (!empty($logger)) {
    $query_start = microtime(TRUE);
  }

  // Prepare the query.
  $statement = $this->getStatement($this->queryString, $args);
  if (!$statement) {
    $this->throwPDOException();
  }

  $return = $statement->execute($args);
  if (!$return) {
    $this->throwPDOException();
  }

  // Fetch all the data from the reply, in order to release any lock
  // as soon as possible.
  $this->rowCount = $statement->rowCount();
  $this->data = $statement->fetchAll(PDO::FETCH_ASSOC);
  // Destroy the statement as soon as possible.
  // See DatabaseConnection_sqlite::PDOPrepare() for explanation.
  // @see DatabaseConnection_sqlite::PDOPrepare()
  unset($statement);

  $this->resultRowCount = count($this->data);

  if ($this->resultRowCount) {
    $this->columnNames = array_keys($this->data[0]);
  }
  else {
    $this->columnNames = array();
  }

  if (!empty($logger)) {
    $query_end = microtime(TRUE);
    $logger->log($this, $args, $query_end - $query_start);
  }

  // Initialize the first row in $this->currentRow.
  $this->next();

  return $return;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen