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. 10 core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php \Drupal\KernelTests\Core\Database\BasicSyntaxTest::testConcatWsFields()
  3. 11.x 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 66

Class

BasicSyntaxTest
Tests SQL syntax interpretation.

Namespace

Drupal\KernelTests\Core\Database

Code

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

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