function FetchTest::testQueryFetchNum in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/FetchTest.php \Drupal\system\Tests\Database\FetchTest::testQueryFetchNum()
Confirms that we can fetch a record into an indexed array explicitly.
File
- core/
modules/ system/ src/ Tests/ Database/ FetchTest.php, line 90 - Contains \Drupal\system\Tests\Database\FetchTest.
Class
- FetchTest
- Tests the Database system's various fetch capabilities.
Namespace
Drupal\system\Tests\DatabaseCode
function testQueryFetchNum() {
$records = array();
$result = db_query('SELECT name FROM {test} WHERE age = :age', array(
':age' => 25,
), array(
'fetch' => \PDO::FETCH_NUM,
));
foreach ($result as $record) {
$records[] = $record;
if ($this
->assertTrue(is_array($record), 'Record is an array.')) {
$this
->assertIdentical($record[0], 'John', 'Record can be accessed numerically.');
}
}
$this
->assertIdentical(count($records), 1, 'There is only one record');
}