function DatabaseAlterTestCase::testAlterChangeFields

Test that we can alter the fields of a query.

File

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

Class

DatabaseAlterTestCase
Select alter tests.

Code

function testAlterChangeFields() {
    $query = db_select('test');
    $name_field = $query->addField('test', 'name');
    $age_field = $query->addField('test', 'age', 'age');
    $query->orderBy('name');
    $query->addTag('database_test_alter_change_fields');
    $record = $query->execute()
        ->fetch();
    $this->assertEqual($record->{$name_field}, 'George', 'Correct data retrieved.');
    $this->assertFalse(isset($record->{$age_field}), 'Age field not found, as intended.');
}

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