function DatabaseQueryTestCase::testArraySubstitution in Drupal 7
Test that we can specify an array of values in the query by simply passing in an array.
File
- modules/
simpletest/ tests/ database_test.test, line 3434
Class
- DatabaseQueryTestCase
- Drupal-specific SQL syntax tests.
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');
}