$query_result =
$query->
execute()->
fetchAll(\PDO::FETCH_COLUMN
);
$expected_result =
['George', 'John', 'Paul', 'Ringo'
];
$this->
assertEquals($expected_result,
$query_result, 'Returned the correct result.'
);
} /**
* Confirms that we can fetch an entire column of a result set at once.
*/
public function testQueryFetchCol() { $result =
$this->connection->
query('SELECT [name] FROM {test} WHERE [age] > :age',
[':age' => 25
]);
$column =
$result->
fetchCol();
$this->
assertCount(3,
$column, 'fetchCol() returns the right number of records.'
);
$result =
$this->connection->
query('SELECT [name] FROM {test} WHERE [age] > :age',
[':age' => 25
]);
$i = 0;
foreach ($result as $record) { $this->
assertSame($column[$i++
],
$record->name, 'Column matches direct access.'
);
} } /**
* Tests ::fetchAllAssoc().
*/