PersistentObject: ezcPersistentFindIterator
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcPersistentFindIterator
|
This class provides functionality to iterate over a database result set in the form of persistent objects. [
source]
Implemented Interfaces
- Iterator (internal interface)
ezcPersistentFindIterator only instantiates one object which is reused for each iteration. This saves memory and is faster than fetching and instantiating the result set in one go.
You must loop over the complete resultset of the iterator or flush it before executing new queries.
Example:
1. $q = $session->createFindQuery( 'Person' );
2. $q->where( $q->expr->gt( 'age', $q->bindValue( 15 ) ) )
3. ->orderBy( 'name' )
4. ->limit( 10 );
5. $objects = $session->findIterator( $q, 'Person' );
6.
7. foreach ( $objects as $object )
8. {
9. if ( ... )
10. {
11. $objects->flush();
12. break;
13. }
14. }
Method Summary
|
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. |
Methods
__construct
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.
Parameters
current
object current(
)
Returns the current object of this iterator.
Returns null if there is no current object.
flush
void flush(
)
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.
key
null key(
)
Returns null.
Persistent objects do not have a key. Hence, this method always returns null.
next
object next(
)
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.
rewind
void rewind(
)
Sets the iterator to point to the first object in the result set.
valid
bool valid(
)
Returns true if there is a current object.
Last updated: Mon, 10 Nov 2008