function ReservedWordTest::testSelectReservedWordAliasSpecificFields

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/ReservedWordTest.php \Drupal\KernelTests\Core\Database\ReservedWordTest::testSelectReservedWordAliasSpecificFields()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/ReservedWordTest.php \Drupal\KernelTests\Core\Database\ReservedWordTest::testSelectReservedWordAliasSpecificFields()
  3. 10 core/tests/Drupal/KernelTests/Core/Database/ReservedWordTest.php \Drupal\KernelTests\Core\Database\ReservedWordTest::testSelectReservedWordAliasSpecificFields()

Tests SELECT query with specific fields from a table with a reserved alias.

File

core/tests/Drupal/KernelTests/Core/Database/ReservedWordTest.php, line 59

Class

ReservedWordTest
Tests queries that include reserved words.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSelectReservedWordAliasSpecificFields() : void {
    $query = $this->connection
        ->select('test', 'high_priority');
    $query->addField('high_priority', 'name');
    $query->addField('high_priority', 'age', 'age');
    $query->condition('age', 27);
    $record = $query->execute()
        ->fetchObject();
    // Ensure that we got the right record.
    $this->assertSame('George', $record->name);
    $this->assertSame('27', $record->age);
}

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