You are here

public function Update::execute in Drupal driver for SQL Server and SQL Azure 8

Same name and namespace in other branches
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Update.php \Drupal\Driver\Database\sqlsrv\Update::execute()
  2. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Update.php \Drupal\Driver\Database\sqlsrv\Update::execute()

Executes the UPDATE query.

Return value

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 Update::execute

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Update.php, line 26
Definition of Drupal\Driver\Database\sqlsrv\Update

Class

Update

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function execute() {

  // Retrieve query options.
  $options = $this->queryOptions;

  // Fetch the list of blobs and sequences used on that table.
  $columnInformation = $this->connection
    ->schema()
    ->queryColumnInformation($this->table);

  // Because we filter $fields the same way here and in __toString(), the
  // placeholders will all match up properly.
  $stmt = $this->connection
    ->prepareQuery((string) $this);

  // Expressions take priority over literal fields, so we process those first
  // and remove any literal fields that conflict.
  $fields = $this->fields;
  DatabaseUtils::BindExpressions($stmt, $this->expressionFields, $fields);

  // We use this array to store references to the blob handles.
  // This is necessary because the PDO will otherwise messes up with references.
  $blobs = array();
  DatabaseUtils::BindValues($stmt, $fields, $blobs, ':db_update_placeholder_', $columnInformation);

  // Add conditions.
  if (count($this->condition)) {
    $this->condition
      ->compile($this->connection, $this);
    $arguments = $this->condition
      ->arguments();
    DatabaseUtils::BindArguments($stmt, $arguments);
  }
  $options = $this->queryOptions;
  $options['already_prepared'] = TRUE;
  $this->connection
    ->query($stmt, array(), $options);
  return $stmt
    ->rowCount();
}