function QueryTest::testArraySubstitution in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/QueryTest.php \Drupal\system\Tests\Database\QueryTest::testArraySubstitution()
Tests that we can pass an array of values directly in the query.
File
- core/
modules/ system/ src/ Tests/ Database/ QueryTest.php, line 20 - Contains \Drupal\system\Tests\Database\QueryTest.
Class
- QueryTest
- Tests Drupal's extended prepared statement syntax..
Namespace
Drupal\system\Tests\DatabaseCode
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');
$names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(
':ages[]' => array(
25,
),
))
->fetchAll();
$this
->assertEqual(count($names), 1, 'Correct number of names returned');
}