StatementIterator.php 464 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Doctrine\DBAL\Driver;
  3. use IteratorAggregate;
  4. class StatementIterator implements IteratorAggregate
  5. {
  6. /** @var Statement */
  7. private $statement;
  8. public function __construct(Statement $statement)
  9. {
  10. $this->statement = $statement;
  11. }
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function getIterator()
  16. {
  17. while (($result = $this->statement->fetch()) !== false) {
  18. yield $result;
  19. }
  20. }
  21. }