Issues

ZF-4486: PDOStatement is of type Traversable, Zend_Db_Statement should be an Iterator

Issue Type: Improvement Created: 2008-10-04T11:55:40.000+0000 Last Updated: 2008-12-22T00:34:38.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: exceptione (exceptione) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db

Related issues: Attachments:

Description

PDOStatement has type Traversable. This is a php-internal type. To my surprise Zend_Db_Statement doesn't expose this interface. I expect at least Zend_Db_Statement_Pdo to be iterative. Iterator extends Traversable and this interface can be used in userland code. Implementing the Iterator interface for Zend_Db_Statement would solve this discrepancy. We can throw an NotImplementedException for rewind().

Comments

Posted by julien PAULI (doctorrock83) on 2008-11-27T08:01:24.000+0000

Perhaps we could use IteratorAggregate.

The getIterator() method could then return the PDOStatement, as return $this->_stmt

Posted by julien PAULI (doctorrock83) on 2008-12-19T06:48:55.000+0000

Something like this works :

<pre class="highlight">
class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggregate
{
   / ...
    public function getIterator()
    {
        return new IteratorIterator($this->_stmt);
    }
}

But I don't know if that is THE solution.

Posted by julien PAULI (doctorrock83) on 2008-12-22T00:34:37.000+0000

r13420 adds the improvement

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts