Upsert::execute

public Upsert::execute()

Runs the query against the database.

Return value

\Drupal\Core\Database\StatementInterface|null A prepared statement, or NULL if the query is not valid.

Overrides Query::execute

File

core/lib/Drupal/Core/Database/Query/Upsert.php, line 93

Class

Upsert
General class for an abstracted "Upsert" (UPDATE or INSERT) query operation.

Namespace

Drupal\Core\Database\Query

Code

public function execute() {
  if (!$this->preExecute()) {
    return NULL;
  }

  $max_placeholder = 0;
  $values = array();
  foreach ($this->insertValues as $insert_values) {
    foreach ($insert_values as $value) {
      $values[':db_insert_placeholder_' . $max_placeholder++] = $value;
    }
  }

  $last_insert_id = $this->connection->query((string) $this, $values, $this->queryOptions);

  // Re-initialize the values array so that we can re-use this query.
  $this->insertValues = array();

  return $last_insert_id;
}
doc_Drupal
2016-10-29 09:51:33
Comments
Leave a Comment

Please login to continue.