function QueryTest::testNumericExpressionSubstitution

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

Tests numeric query parameter expansion in expressions.

See also

\Drupal\sqlite\Driver\Database\sqlite\Statement::getStatement()

http://bugs.php.net/bug.php?id=45259

File

core/tests/Drupal/KernelTests/Core/Database/QueryTest.php, line 151

Class

QueryTest
Tests Drupal's extended prepared statement syntax..

Namespace

Drupal\KernelTests\Core\Database

Code

public function testNumericExpressionSubstitution() : void {
    $count_expected = $this->connection
        ->query('SELECT COUNT(*) + 3 FROM {test}')
        ->fetchField();
    $count = $this->connection
        ->query('SELECT COUNT(*) + :count FROM {test}', [
        ':count' => 3,
    ])
        ->fetchField();
    $this->assertEquals($count_expected, $count);
}

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