function FetchTest::testQueryFetchColumn
Confirms that we can fetch a single column value.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ FetchTest.php, line 41
Class
- FetchTest
- Tests the Database system's various fetch capabilities.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testQueryFetchColumn() : void {
$statement = $this->connection
->query('SELECT [name] FROM {test} WHERE [age] = :age', [
':age' => 25,
]);
$statement->setFetchMode(\PDO::FETCH_COLUMN, 0);
$this->assertSame('John', $statement->fetch());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.