Beispiel #1
0
 /**
  * Construct a new xPDOIterator instance (do not call directly).
  *
  * @see xPDO::getIterator()
  * @param xPDO &$xpdo A reference to a valid xPDO instance.
  * @param array $options An array of options for the iterator.
  * @return xPDOIterator An xPDOIterator instance.
  */
 function __construct(&$xpdo, array $options = array())
 {
     $this->xpdo =& $xpdo;
     if (isset($options['class'])) {
         $this->class = $this->xpdo->loadClass($options['class']);
     }
     if (isset($options['alias'])) {
         $this->alias = $options['alias'];
     } else {
         $this->alias = $this->class;
     }
     if (isset($options['cacheFlag'])) {
         $this->cacheFlag = $options['cacheFlag'];
     }
     if (array_key_exists('criteria', $options) && is_object($options['criteria'])) {
         $this->criteria = $options['criteria'];
     } elseif (!empty($this->class)) {
         $criteria = array_key_exists('criteria', $options) ? $options['criteria'] : null;
         $this->criteria = $this->xpdo->getCriteria($this->class, $criteria, $this->cacheFlag);
     }
     if (!empty($this->criteria)) {
         $this->criteriaType = $this->xpdo->getCriteriaType($this->criteria);
         if ($this->criteriaType === 'xPDOQuery') {
             $this->class = $this->criteria->getClass();
             $this->alias = $this->criteria->getAlias();
         }
     }
 }