function BasicSyntaxTest::testConcatWsFields

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

Tests string concatenation with separator, with field values.

File

core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php, line 68

Class

BasicSyntaxTest
Tests SQL syntax interpretation.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testConcatWsFields() : void {
    $result = $this->connection
        ->query("SELECT CONCAT_WS('-', :a1, [name], :a2, [age]) FROM {test} WHERE [age] = :age", [
        ':a1' => 'name',
        ':a2' => 'age',
        ':age' => 25,
    ]);
    $this->assertSame('name-John-age-25', $result->fetchField());
}

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