function QueryTest::testNumericExpressionSubstitution

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest::testNumericExpressionSubstitution()
  2. 10 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\Core\Database\Driver\sqlite\Statement::getStatement()

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

File

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

Class

QueryTest
Tests Drupal's extended prepared statement syntax..

Namespace

Drupal\KernelTests\Core\Database

Code

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

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