db_insert

Definition

db_insert($table, array $options = array())
drupal/includes/database/database.inc, line 1692

Description

Returns a new InsertQuery object for the active database.

Parameters

$table The table into which to insert.

$options An array of options to control how the query operates.

Return value

A new InsertQuery object for this connection.

Related topics

Namesort iconDescription
Database abstraction layerAllow the use of different database servers using the same code base.

Code

function db_insert($table, array $options = array()) {
  if (empty($options['target']) || $options['target'] == 'slave') {
    $options['target'] = 'default';
  }
  return Database::getActiveConnection($options['target'])->insert($table, $options);
}