function DatabaseInsertTestCase::testInsertLastInsertID

Test that inserts return the proper auto-increment ID.

File

modules/simpletest/tests/database_test.test, line 665

Class

DatabaseInsertTestCase
Test the insert builder.

Code

function testInsertLastInsertID() {
    $id = db_insert('test')->fields(array(
        'name' => 'Larry',
        'age' => '30',
    ))
        ->execute();
    $this->assertIdentical($id, '5', 'Auto-increment ID returned successfully.');
}

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