execute

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

Verwandte Themen

Code

includes/database/sqlite/database.inc, line 227

<?php
public function execute($args = array(), $options = array()) {
  try {
    $return = parent::execute($args, $options);
  }
  catch (PDOException $e) {
    if (!empty($e->errorInfo[1]) && $e->errorInfo[1] === 17) {
      // The schema has changed. SQLite specifies that we must resend the query.
      $return = parent::execute($args, $options);
    }
    else {
      // Rethrow the exception.
      throw $e;
    }
  }

  // In some weird cases, 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 MySQL and PostgreSQL.
  $rename_columns = array();
  foreach ($this->columnNames as $k => $column) {
    // In some SQLite versions, SELECT DISTINCT(field) will return "(field)"
    // instead of "field".
    if (preg_match("/^\((.*)\)$/", $column, $matches)) {
      $rename_columns[$column] = $matches[1];
      $this->columnNames[$k] = $matches[1];
      $column = $matches[1];
    }

    // Remove "table." prefixes.
    if (preg_match("/^.*\.(.*)$/", $column, $matches)) {
      $rename_columns[$column] = $matches[1];
      $this->columnNames[$k] = $matches[1];
    }
  }
  if ($rename_columns) {
    // DatabaseStatementPrefetch already extracted the first row,
    // put it back into the result set.
    if (isset($this->currentRow)) {
      $this->data[0] = &$this->currentRow;
    }

    // Then rename all the columns across the result set.
    foreach ($this->data as $k => $row) {
      foreach ($rename_columns as $old_column => $new_column) {
        $this->data[$k][$new_column] = $this->data[$k][$old_column];
        unset($this->data[$k][$old_column]);
      }
    }

    // Finally, extract the first row again.
    $this->currentRow = $this->data[0];
    unset($this->data[0]);
  }

  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