function DatabaseUpdateTestCase::testMultiUpdate

Confirm that we can update a multiple records successfully.

File

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

Class

DatabaseUpdateTestCase
Update builder tests.

Code

function testMultiUpdate() {
    $num_updated = db_update('test')->fields(array(
        'job' => 'Musician',
    ))
        ->condition('job', 'Singer')
        ->execute();
    $this->assertIdentical($num_updated, 2, 'Updated 2 records.');
    $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(
        ':job' => 'Musician',
    ))->fetchField();
    $this->assertIdentical($num_matches, '2', 'Updated fields successfully.');
}

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