## Apache Zeta Components Manual :: Docs For Class ezcPersistentFindIterator

### PersistentObject::ezcPersistentFindIterator

### Class ezcPersistentFindIterator

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:

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');
7. foreach($objectsas$object)
8. {
9. if(...)
10. {
11. $objects-> flush ();
12. break;
13. }
14. }

Source for this file: /PersistentObject/src/find_iterator.php

### Implements interfaces:

- Iterator (internal interface)

Version: | //autogen//

### Descendants

Child Class | Description
--- | ---
ezcPersistentIdentityFindIterator | Iterator class with identity mapping facilities.

### Member Variables

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.

### 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

ezcPersistentFindIterator __construct( $stmt , ezcPersistentObjectDefinition $def )

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:

Name | Type | Description
--- | --- | ---
`$stmt` | PDOStatement |
`$def` | ezcPersistentObjectDefinition |

##### Redefined in descendants as:

Method | Description
--- | ---
`ezcPersistentIdentityFindIterator::__construct()` | Initializes the iterator with the statement $stmt and the definition $def..

#### current

object current( )

Returns the current object of this iterator.

Returns null if there is no current object.

##### Implementation of:

Method | Description
--- | ---
`Iterator::current` |

#### 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.

##### Implementation of:

Method | Description
--- | ---
`Iterator::key` |

#### 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.

##### Implementation of:

Method | Description
--- | ---
`Iterator::next` |

##### Redefined in descendants as:

Method | Description
--- | ---
`ezcPersistentIdentityFindIterator::next()` | Returns the next persistent object in the result set.

#### rewind

void rewind( )

Sets the iterator to point to the first object in the result set.

##### Implementation of:

Method | Description
--- | ---
`Iterator::rewind` |

#### valid

bool valid( )

Returns true if there is a current object.

##### Implementation of:

Method | Description
--- | ---
`Iterator::valid` |

Documentation generated by phpDocumentor 1.4.3