src/xPDO/Om/xPDOObject.php
public function getIterator($alias, $criteria= null, $cacheFlag= true) {
        $iterator = false;
        $fkMeta= $this->getFKDefinition($alias);
        if ($fkMeta) {
            $fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : null;
            if ($criteria === null) {
                $criteria= array($fkMeta['foreign'] => $this->get($fkMeta['local']));
                if ($fkCriteria !== null) {
                    $criteria = array($fkCriteria, $criteria);
                }
            } else {
                $criteria= $this->xpdo->newQuery($fkMeta['class'], $criteria);
                $addCriteria = array("{$criteria->getAlias()}.{$fkMeta['foreign']}" => $this->get($fkMeta['local']));
                if ($fkCriteria !== null) {
                    $fkAddCriteria = array();
                    foreach ($fkCriteria as $fkCritKey => $fkCritVal) {
                        if (is_numeric($fkCritKey)) continue;
                        $fkAddCriteria["{$criteria->getAlias()}.{$fkCritKey}"] = $fkCritVal;
                    }
                    if (!empty($fkAddCriteria)) {
                        $addCriteria = array($fkAddCriteria, $addCriteria);
                    }
                }
                $criteria->andCondition($addCriteria);
            }
            $iterator = $this->xpdo->getIterator($fkMeta['class'], $criteria, $cacheFlag);
        }
        return $iterator;
    }
public function getIterator($alias, $criteria= null, $cacheFlag= true) {
        $iterator = false;
        $fkMeta= $this->getFKDefinition($alias);
        if ($fkMeta) {
            $fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : null;
            if ($criteria === null) {
                $criteria= array($fkMeta['foreign'] => $this->get($fkMeta['local']));
                if ($fkCriteria !== null) {
                    $criteria = array($fkCriteria, $criteria);
                }
            } else {
                $criteria= $this->xpdo->newQuery($fkMeta['class'], $criteria);
                $addCriteria = array("{$criteria->getAlias()}.{$fkMeta['foreign']}" => $this->get($fkMeta['local']));
                if ($fkCriteria !== null) {
                    $fkAddCriteria = array();
                    foreach ($fkCriteria as $fkCritKey => $fkCritVal) {
                        if (is_numeric($fkCritKey)) continue;
                        $fkAddCriteria["{$criteria->getAlias()}.{$fkCritKey}"] = $fkCritVal;
                    }
                    if (!empty($fkAddCriteria)) {
                        $addCriteria = array($fkAddCriteria, $addCriteria);
                    }
                }
                $criteria->andCondition($addCriteria);
            }
            $iterator = $this->xpdo->getIterator($fkMeta['class'], $criteria, $cacheFlag);
        }
        return $iterator;
    }
public function getIterator ( $ alias , $ criteria = null , $ cacheFlag = true ) { $ iterator = false ; $ fkMeta = $ this -> getFKDefinition ( $ alias ) ; if ( $ fkMeta ) { $ fkCriteria = isset ( $ fkMeta [ 'criteria' ] ) && isset ( $ fkMeta [ 'criteria' ] [ 'foreign' ] ) ? $ fkMeta [ 'criteria' ] [ 'foreign' ] : null ; if ( $ criteria === null ) { $ criteria = array ( $ fkMeta [ 'foreign' ] => $ this -> get ( $ fkMeta [ 'local' ] ) ) ; if ( $ fkCriteria !== null ) { $ criteria = array ( $ fkCriteria , $ criteria ) ; } } else { $ criteria = $ this -> xpdo -> newQuery ( $ fkMeta [ 'class' ] , $ criteria ) ; $ addCriteria = array ( "{$criteria->getAlias()}.{$fkMeta['foreign']}" => $ this -> get ( $ fkMeta [ 'local' ] ) ) ; if ( $ fkCriteria !== null ) { $ fkAddCriteria = array ( ) ; foreach ( $ fkCriteria as $ fkCritKey => $ fkCritVal ) { if ( is_numeric ( $ fkCritKey ) ) continue ; $ fkAddCriteria [ "{$criteria->getAlias()}.{$fkCritKey}" ] = $ fkCritVal ; } if ( ! empty ( $ fkAddCriteria ) ) { $ addCriteria = array ( $ fkAddCriteria , $ addCriteria ) ; } } $ criteria -> andCondition ( $ addCriteria ) ; } $ iterator = $ this -> xpdo -> getIterator ( $ fkMeta [ 'class' ] , $ criteria , $ cacheFlag ) ; } return $ iterator ; }
Get an xPDOIterator for a collection of objects related by aggregate or composite relations.

@param string $alias The alias of the relation.
@param null|array|xPDOCriteria $criteria A valid xPDO criteria expression.
@param bool|int $cacheFlag Indicates if the objects should be cached and optionally, by
specifying  an integer values, for how many seconds.
@return bool|xPDOIterator An iterator for the collection or false if no relation is found.
Get an xPDOIterator for a collection of objects related by aggregate or composite relations .