function db_insert

Same name in other branches
  1. 8.9.x core/includes/database.inc \db_insert()

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

InsertQuery A new InsertQuery object for this connection.

Related topics

3 calls to db_insert()
DatabaseInsertTestCase::testMultiInsert in modules/simpletest/tests/database_test.test
Test that we can insert multiple records in one query object.
DatabaseInsertTestCase::testRepeatedInsert in modules/simpletest/tests/database_test.test
Test that an insert object can be reused with new data after it executes.
DatabaseInsertTestCase::testSimpleInsert in modules/simpletest/tests/database_test.test
Test the very basic insert functionality.

File

includes/database/database.inc, line 2543

Code

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

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