| 7 database_test.test | DatabaseFetch2TestCase::testQueryFetchBoth() |
| 8 database.test | DatabaseFetch2TestCase::testQueryFetchBoth() |
Confirm that we can fetch a record into a doubly-keyed array explicitly.
File
- modules/
simpletest/ tests/ database_test.test, line 401
Code
function testQueryFetchBoth() {
$records = array();
$result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => PDO::FETCH_BOTH));
foreach ($result as $record) {
$records[] = $record;
if ($this->assertTrue(is_array($record), t('Record is an array.'))) {
$this->assertIdentical($record[0], 'John', t('Record can be accessed numerically.'));
$this->assertIdentical($record['name'], 'John', t('Record can be accessed associatively.'));
}
}
$this->assertIdentical(count($records), 1, t('There is only one record.'));
}
Login or register to post comments