Path

ez components / documentation / api reference / trunk / persistentobject


eZ Components trunk

PersistentObject: ezcPersistentFindIterator

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

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)

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->bindValue15 ) ) )
 3.     ->orderBy'name' )
 4.     ->limit10 );
 5.   $objects $session->findIterator$q'Person' );
 6.  
 7.   foreach $objects as $object )
 8.   {
 9.      if ... )
10.      {
11.         $objects->flush();
12.         break;
13.      }
14.   }

Descendents

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.

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.

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.

valid

bool valid( )
Returns true if there is a current object.

Last updated: Mon, 21 Dec 2009