function DatabaseUpdateTestCase::testSimpleNullUpdate

Confirm updating to NULL.

File

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

Class

DatabaseUpdateTestCase
Update builder tests.

Code

function testSimpleNullUpdate() {
    $this->ensureSampleDataNull();
    $num_updated = db_update('test_null')->fields(array(
        'age' => NULL,
    ))
        ->condition('name', 'Kermit')
        ->execute();
    $this->assertIdentical($num_updated, 1, 'Updated 1 record.');
    $saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', array(
        ':name' => 'Kermit',
    ))->fetchField();
    $this->assertNull($saved_age, 'Updated name successfully.');
}

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