function Update::execute

Same name in this branch
  1. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Update.php \Drupal\pgsql\Driver\Database\pgsql\Update::execute()
Same name in other branches
  1. 9 core/modules/pgsql/src/Driver/Database/pgsql/Update.php \Drupal\pgsql\Driver\Database\pgsql\Update::execute()
  2. 9 core/lib/Drupal/Core/Database/Query/Update.php \Drupal\Core\Database\Query\Update::execute()
  3. 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Update.php \Drupal\Core\Database\Driver\pgsql\Update::execute()
  4. 8.9.x core/lib/Drupal/Core/Database/Query/Update.php \Drupal\Core\Database\Query\Update::execute()
  5. 10 core/modules/pgsql/src/Driver/Database/pgsql/Update.php \Drupal\pgsql\Driver\Database\pgsql\Update::execute()
  6. 10 core/lib/Drupal/Core/Database/Query/Update.php \Drupal\Core\Database\Query\Update::execute()

Executes the UPDATE query.

Return value

int|null The number of rows matched by the update query. This includes rows that actually didn't have to be updated because the values didn't change.

Overrides Query::execute

1 method overrides Update::execute()
Update::execute in core/modules/pgsql/src/Driver/Database/pgsql/Update.php
Executes the UPDATE query.

File

core/lib/Drupal/Core/Database/Query/Update.php, line 118

Class

Update
General class for an abstracted UPDATE operation.

Namespace

Drupal\Core\Database\Query

Code

public function execute() {
    [
        $args,
        $update_values,
    ] = $this->getQueryArguments();
    $update_values += $args;
    if (count($this->condition)) {
        $this->condition
            ->compile($this->connection, $this);
        $update_values = array_merge($update_values, $this->condition
            ->arguments());
    }
    $stmt = $this->connection
        ->prepareStatement((string) $this, $this->queryOptions, TRUE);
    try {
        $stmt->execute($update_values, $this->queryOptions);
        return $stmt->rowCount();
    } catch (\Exception $e) {
        $this->connection
            ->exceptionHandler()
            ->handleExecutionException($e, $stmt, $update_values, $this->queryOptions);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.