This class provides functionality to iterate over a database result set in the form of persistent objects.
Note: The iterator does not return only a single instance anymore, since this has been fixed as a bug fix. A new instance is cloned for each iteration step.
You must loop over the complete resultset of the iterator or flush it before executing new queries.
Example:
Source for this file: /PersistentObject/src/find_iterator.php
Version: | //autogen// |
Child Class | Description |
---|---|
ezcPersistentIdentityFindIterator | Iterator class with identity mapping facilities. |
protected mixed |
$def
= null
The definition of the persistent object type. $var ezcPersistentObjectDefinition |
protected object |
$object
= null
Stores the current object of the iterator. This variable is null if there is no current object. |
public ezcPersistentFindIterator |
__construct(
$stmt
, $def
)
Initializes the iterator with the statement $stmt and the definition $def.. |
public object |
current(
)
Returns the current object of this iterator. |
public void |
flush(
)
Clears the results from the iterator. |
public null |
key(
)
Returns null. |
public object |
next(
)
Returns the next persistent object in the result set. |
public void |
rewind(
)
Sets the iterator to point to the first object in the result set. |
public bool |
valid(
)
Returns true if there is a current object. |
Initializes the iterator with the statement $stmt and the definition $def..
The statement $stmt must be executed but not used to retrieve any results yet. The iterator will return objects with they persistent object type provided by $def.
Name | Type | Description |
---|---|---|
$stmt |
PDOStatement | |
$def |
ezcPersistentObjectDefinition |
Method | Description |
---|---|
ezcPersistentIdentityFindIterator::__construct() |
Initializes the iterator with the statement $stmt and the definition $def.. |
Returns the current object of this iterator.
Returns null if there is no current object.
Method | Description |
---|---|
Iterator::current |
Clears the results from the iterator.
This method must be called if you decide not to iterate over the complete resultset. Failure to do so may result in errors on subsequent SQL queries.
Returns null.
Persistent objects do not have a key. Hence, this method always returns null.
Method | Description |
---|---|
Iterator::key |
Returns the next persistent object in the result set.
The next object is set to the current object of the iterator. Returns null and sets the current object to null if there are no more results in the result set.
Method | Description |
---|---|
Iterator::next |
Method | Description |
---|---|
ezcPersistentIdentityFindIterator::next() |
Returns the next persistent object in the result set. |
Sets the iterator to point to the first object in the result set.
Method | Description |
---|---|
Iterator::rewind |
Returns true if there is a current object.
Method | Description |
---|---|
Iterator::valid |