function Merge::insertFields

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::insertFields()
  2. 8.9.x core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::insertFields()
  3. 11.x core/lib/Drupal/Core/Database/Query/Merge.php \Drupal\Core\Database\Query\Merge::insertFields()

Adds a set of field->value pairs to be inserted.

Parameters

$fields: An array of fields on which to insert. This array may be indexed or associative. If indexed, the array is taken to be the list of fields. If associative, the keys of the array are taken to be the fields and the values are taken to be corresponding values to insert. If a $values argument is provided, $fields must be indexed.

$values: An array of fields to insert into the database. The values must be specified in the same order as the $fields array.

Return value

$this The called object.

File

core/lib/Drupal/Core/Database/Query/Merge.php, line 221

Class

Merge
General class for an abstracted MERGE query operation.

Namespace

Drupal\Core\Database\Query

Code

public function insertFields(array $fields, array $values = []) {
    if ($values) {
        $fields = array_combine($fields, $values);
    }
    $this->insertFields = $fields;
    return $this;
}

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