You are here

public function QueryTest::testNumericExpressionSubstitution in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/QueryTest.php \Drupal\system\Tests\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/modules/system/src/Tests/Database/QueryTest.php, line 143
Contains \Drupal\system\Tests\Database\QueryTest.

Class

QueryTest
Tests Drupal's extended prepared statement syntax..

Namespace

Drupal\system\Tests\Database

Code

public function testNumericExpressionSubstitution() {
  $count = db_query('SELECT COUNT(*) >= 3 FROM {test}')
    ->fetchField();
  $this
    ->assertEqual((bool) $count, TRUE);
  $count = db_query('SELECT COUNT(*) >= :count FROM {test}', array(
    ':count' => 3,
  ))
    ->fetchField();
  $this
    ->assertEqual((bool) $count, TRUE);
}