function DatabaseUpdateTestCase::testSimpleUpdate

Confirm that we can update a single record successfully.

File

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

Class

DatabaseUpdateTestCase
Update builder tests.

Code

function testSimpleUpdate() {
    $num_updated = db_update('test')->fields(array(
        'name' => 'Tiffany',
    ))
        ->condition('id', 1)
        ->execute();
    $this->assertIdentical($num_updated, 1, 'Updated 1 record.');
    $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', array(
        ':id' => 1,
    ))->fetchField();
    $this->assertIdentical($saved_name, 'Tiffany', 'Updated name successfully.');
}

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