src/xPDO/Om/xPDOObject.php
public static function loadCollection(xPDO & $xpdo, $className, $criteria= null, $cacheFlag= true) {
        $objCollection= array ();
        $fromCache = false;
        if (!$className= $xpdo->loadClass($className)) return $objCollection;
        $rows= false;
        $fromCache= false;
        $collectionCaching = (integer) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
        if (!is_object($criteria)) {
            $criteria= $xpdo->getCriteria($className, $criteria, $cacheFlag);
        }
        if (is_object($criteria)) {
            $criteria = $xpdo->addDerivativeCriteria($className, $criteria);
        }
        if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
            $rows= $xpdo->fromCache($criteria);
            $fromCache = (is_array($rows) && !empty($rows));
        }
        if (!$fromCache && is_object($criteria)) {
            $rows= xPDOObject :: _loadRows($xpdo, $className, $criteria);
        }
        if (is_array ($rows)) {
            foreach ($rows as $row) {
                xPDOObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
            }
        } elseif (is_object($rows)) {
            $cacheRows = array();
            while ($row = $rows->fetch(\PDO::FETCH_ASSOC)) {
                xPDOObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
                if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) $cacheRows[] = $row;
            }
            if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) $rows =& $cacheRows;
        }
        if (!$fromCache && $xpdo->_cacheEnabled && $collectionCaching > 0 && $cacheFlag && !empty($rows)) {
            $xpdo->toCache($criteria, $rows, $cacheFlag);
        }
        return $objCollection;
    }
public static function loadCollection(xPDO & $xpdo, $className, $criteria= null, $cacheFlag= true) {
        $objCollection= array ();
        $fromCache = false;
        if (!$className= $xpdo->loadClass($className)) return $objCollection;
        $rows= false;
        $fromCache= false;
        $collectionCaching = (integer) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
        if (!is_object($criteria)) {
            $criteria= $xpdo->getCriteria($className, $criteria, $cacheFlag);
        }
        if (is_object($criteria)) {
            $criteria = $xpdo->addDerivativeCriteria($className, $criteria);
        }
        if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
            $rows= $xpdo->fromCache($criteria);
            $fromCache = (is_array($rows) && !empty($rows));
        }
        if (!$fromCache && is_object($criteria)) {
            $rows= xPDOObject :: _loadRows($xpdo, $className, $criteria);
        }
        if (is_array ($rows)) {
            foreach ($rows as $row) {
                xPDOObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
            }
        } elseif (is_object($rows)) {
            $cacheRows = array();
            while ($row = $rows->fetch(\PDO::FETCH_ASSOC)) {
                xPDOObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
                if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) $cacheRows[] = $row;
            }
            if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) $rows =& $cacheRows;
        }
        if (!$fromCache && $xpdo->_cacheEnabled && $collectionCaching > 0 && $cacheFlag && !empty($rows)) {
            $xpdo->toCache($criteria, $rows, $cacheFlag);
        }
        return $objCollection;
    }
public static function loadCollection ( xPDO & $ xpdo , $ className , $ criteria = null , $ cacheFlag = true ) { $ objCollection = array ( ) ; $ fromCache = false ; if ( ! $ className = $ xpdo -> loadClass ( $ className ) ) return $ objCollection ; $ rows = false ; $ fromCache = false ; $ collectionCaching = ( integer ) $ xpdo -> getOption ( xPDO :: OPT_CACHE_DB_COLLECTIONS , array ( ) , 1 ) ; if ( ! is_object ( $ criteria ) ) { $ criteria = $ xpdo -> getCriteria ( $ className , $ criteria , $ cacheFlag ) ; } if ( is_object ( $ criteria ) ) { $ criteria = $ xpdo -> addDerivativeCriteria ( $ className , $ criteria ) ; } if ( $ collectionCaching > 0 && $ xpdo -> _cacheEnabled && $ cacheFlag ) { $ rows = $ xpdo -> fromCache ( $ criteria ) ; $ fromCache = ( is_array ( $ rows ) && ! empty ( $ rows ) ) ; } if ( ! $ fromCache && is_object ( $ criteria ) ) { $ rows = xPDOObject :: _loadRows ( $ xpdo , $ className , $ criteria ) ; } if ( is_array ( $ rows ) ) { foreach ( $ rows as $ row ) { xPDOObject :: _loadCollectionInstance ( $ xpdo , $ objCollection , $ className , $ criteria , $ row , $ fromCache , $ cacheFlag ) ; } } elseif ( is_object ( $ rows ) ) { $ cacheRows = array ( ) ; while ( $ row = $ rows -> fetch ( \ PDO :: FETCH_ASSOC ) ) { xPDOObject :: _loadCollectionInstance ( $ xpdo , $ objCollection , $ className , $ criteria , $ row , $ fromCache , $ cacheFlag ) ; if ( $ collectionCaching > 0 && $ xpdo -> _cacheEnabled && $ cacheFlag && ! $ fromCache ) $ cacheRows [ ] = $ row ; } if ( $ collectionCaching > 0 && $ xpdo -> _cacheEnabled && $ cacheFlag && ! $ fromCache ) $ rows = & $ cacheRows ; } if ( ! $ fromCache && $ xpdo -> _cacheEnabled && $ collectionCaching > 0 && $ cacheFlag && ! empty ( $ rows ) ) { $ xpdo -> toCache ( $ criteria , $ rows , $ cacheFlag ) ; } return $ objCollection ; }
Load a collection of xPDOObject instances.

@static
@param xPDO &$xpdo A valid xPDO instance.
@param string $className Name of the class.
@param mixed $criteria A valid primary key, criteria array, or xPDOCriteria instance.
@param boolean|integer $cacheFlag Indicates if the objects should be
cached and optionally, by specifying an integer value, for how many
seconds.
@return array An array of xPDOObject instances or an empty array if no instances are loaded.
Load a collection of xPDOObject instances .