function QueryTest::testArraySubstitution

Tests that we can pass an array of values directly in the query.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Database/QueryTest.php, line 25
Definition of Drupal\system\Tests\Database\QueryTest.

Class

QueryTest
Tests Drupal-specific SQL syntax tests.

Namespace

Drupal\system\Tests\Database

Code

function testArraySubstitution() {
  $names = db_query('SELECT name FROM {test} WHERE age IN (:ages) ORDER BY age', array(
    ':ages' => array(
      25,
      26,
      27,
    ),
  ))
    ->fetchAll();
  $this
    ->assertEqual(count($names), 3, 'Correct number of names returned');
}