function SqlModeTest::testQuotingIdentifiers

Same name in other branches
  1. 10 core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php \Drupal\Tests\mysql\Kernel\mysql\SqlModeTest::testQuotingIdentifiers()
  2. 11.x core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php \Drupal\Tests\mysql\Kernel\mysql\SqlModeTest::testQuotingIdentifiers()

Tests quoting identifiers in queries.

File

core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php, line 17

Class

SqlModeTest
Tests compatibility of the MySQL driver with various sql_mode options.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

public function testQuotingIdentifiers() : void {
    // Use SQL-reserved words for both the table and column names.
    $query = $this->connection
        ->query('SELECT [update] FROM {select}');
    $this->assertEquals('Update value 1', $query->fetchObject()->update);
    $this->assertStringContainsString('SELECT `update` FROM `', $query->getQueryString());
}

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