Path

ez components / documentation / api reference / 2009.1.2 / persistentobject


eZ Components 2009.1.2

PersistentObject: ezcPersistentIdentityFindIterator

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

Class: ezcPersistentIdentityFindIterator

Iterator class with identity mapping facilities. [source]
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. This class in addition performs identity mapping and does not re-created objects that already exist in the application scope.
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.   }

Parents

ezcPersistentFindIterator
   |
   --ezcPersistentIdentityFindIterator

Member Variables

protected ezcPersistentIdentityMap $idMap
Identity map.
protected ezcPersistentSessionIdentityDecoratorOptions $options
Identity session options

Inherited Member Variables

From ezcPersistentFindIterator:
protected  ezcPersistentFindIterator::$def
protected  ezcPersistentFindIterator::$object

Method Summary

public ezcPersistentIdentityFindIterator __construct( $stmt, $def, $idMap, $options )
Initializes the iterator with the statement $stmt and the definition $def..
public object next( )
Returns the next persistent object in the result set.

Inherited Methods

From ezcPersistentFindIterator :
public ezcPersistentFindIterator ezcPersistentFindIterator::__construct()
Initializes the iterator with the statement $stmt and the definition $def..
public object ezcPersistentFindIterator::current()
Returns the current object of this iterator.
public void ezcPersistentFindIterator::flush()
Clears the results from the iterator.
public null ezcPersistentFindIterator::key()
Returns null.
public object ezcPersistentFindIterator::next()
Returns the next persistent object in the result set.
public void ezcPersistentFindIterator::rewind()
Sets the iterator to point to the first object in the result set.
public bool ezcPersistentFindIterator::valid()
Returns true if there is a current object.

Methods

__construct

ezcPersistentIdentityFindIterator __construct( $stmt, ezcPersistentObjectDefinition $def, ezcPersistentIdentityMap $idMap, ezcPersistentSessionIdentityDecoratorOptions $options )
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.
The $idMap will be used to retrieve existing identities and to store new ones, if discovered. The $options object contains the options used by the identity decorator which uses this instance.

Parameters

Name Type Description
$stmt PDOStatement  
$def ezcPersistentObjectDefinition  
$idMap ezcPersistentIdentityMap  
$options ezcPersistentSessionIdentityDecoratorOptions  

Redefinition of

Method Description
ezcPersistentFindIterator::__construct() Initializes the iterator with the statement $stmt and the definition $def..

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.

Redefinition of

Method Description
ezcPersistentFindIterator::next() Returns the next persistent object in the result set.

Last updated: Tue, 01 Sep 2009