function SqlModeTest::testQuotingIdentifiers

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

Tests quoting identifiers in queries.

File

core/modules/mysqli/tests/src/Kernel/mysqli/SqlModeTest.php, line 19

Class

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

Namespace

Drupal\Tests\mysqli\Kernel\mysqli

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.