InsertQuery::values

public function InsertQuery::values

public InsertQuery::values(array $values)

Adds another set of values to the query to be inserted.

If $values is a numeric-keyed array, it will be assumed to be in the same order as the original fields() call. If it is associative, it may be in any order as long as the keys of the array match the names of the fields.

Parameters

$values: An array of values to add to the query.

Return value

InsertQuery The called object.

File

includes/database/query.inc, line 557
Non-specific Database query code. Used by all engines.

Class

InsertQuery
General class for an abstracted INSERT query.

Code

public function values(array $values) {
  if (is_numeric(key($values))) {
    $this->insertValues[] = $values;
  }
  else {
    // Reorder the submitted values to match the fields array.
    foreach ($this->insertFields as $key) {
      $insert_values[$key] = $values[$key];
    }
    // For consistency, the values array is always numerically indexed.
    $this->insertValues[] = array_values($insert_values);
  }
  return $this;
}

© 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!query.inc/function/InsertQuery::values/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部