StatementIterator.php 562 B

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