public function UpdateQuery_sqlite::execute

public UpdateQuery_sqlite::execute()

Executes the UPDATE query.

Return value

The number of rows affected by the update.

Overrides UpdateQuery::execute

File

includes/database/sqlite/query.inc, line 66
Query code for SQLite embedded database engine.

Class

UpdateQuery_sqlite
SQLite specific implementation of UpdateQuery.

Code

public function execute() {
  if (!empty($this->queryOptions['sqlite_return_matched_rows'])) {
    return parent::execute();
  }

  // Get the fields used in the update query.
  $fields = $this->expressionFields + $this->fields;

  // Add the inverse of the fields to the condition.
  $condition = new DatabaseCondition('OR');
  foreach ($fields as $field => $data) {
    if (is_array($data)) {
      // The field is an expression.
      $condition->where($field . ' <> ' . $data['expression']);
      $condition->isNull($field);
    }
    elseif (!isset($data)) {
      // The field will be set to NULL.
      $condition->isNotNull($field);
    }
    else {
      $condition->condition($field, $data, '<>');
      $condition->isNull($field);
    }
  }
  if (count($condition)) {
    $condition->compile($this->connection, $this);
    $this->condition->where((string) $condition, $condition->arguments());
  }
  return parent::execute();
}

© 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/includes!database!sqlite!query.inc/function/UpdateQuery_sqlite::execute/7.x