function StatementTest::testPartiallyIteratedStatementFetchCol
Tests statement fetchCol after a partial traversal.
File
- 
              core/tests/ Drupal/ KernelTests/ Core/ Database/ StatementTest.php, line 152 
Class
- StatementTest
- Tests the Statement classes.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testPartiallyIteratedStatementFetchCol() : void {
  $statement = $this->connection
    ->query('SELECT * FROM {test}');
  for ($i = 0; $i < 2; $i++) {
    $statement->fetch();
  }
  $expected = [
    "3",
    "4",
  ];
  $this->assertSame($expected, $statement->fetchCol());
  $this->assertSame([], $statement->fetchCol());
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
