function DatabaseFetchTestCase::testQueryFetchArray in SimpleTest 7
Confirm that we can fetch a record to an array associative explicitly.
File
- tests/
database_test.test, line 297
Class
- DatabaseFetchTestCase
- Test fetch actions, part 1.
Code
function testQueryFetchArray() {
$records = array();
$result = db_query('SELECT name FROM {test} WHERE age = :age', array(
':age' => 25,
), array(
'fetch' => PDO::FETCH_ASSOC,
));
foreach ($result as $record) {
$records[] = $record;
if ($this
->assertTrue(is_array($record), t('Record is an array.'))) {
$this
->assertIdentical($record['name'], 'John', t('Record can be accessed associatively.'));
}
}
$this
->assertIdentical(count($records), 1, t('There is only one record.'));
}