当前位置: 首页>>代码示例>>PHP>>正文


PHP xPDO::addDerivativeCriteria方法代码示例

本文整理汇总了PHP中xPDO::addDerivativeCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::addDerivativeCriteria方法的具体用法?PHP xPDO::addDerivativeCriteria怎么用?PHP xPDO::addDerivativeCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xPDO的用法示例。


在下文中一共展示了xPDO::addDerivativeCriteria方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadCollection

 /**
  * {@inheritDoc}
  * @return array
  */
 public static function loadCollection(xPDO &$xpdo, $className, $criteria = null, $cacheFlag = true)
 {
     if (!is_object($criteria)) {
         $criteria = $xpdo->getCriteria($className, $criteria, $cacheFlag);
     }
     $xpdo->addDerivativeCriteria($className, $criteria);
     return parent::loadCollection($xpdo, $className, $criteria, $cacheFlag);
 }
开发者ID:rafull6,项目名称:texno-service,代码行数:12,代码来源:mscategory.class.php

示例2: loadCollectionGraph

 /**
  * Load a collection of xPDOObject instances and a graph of related objects.
  *
  * @static
  * @param xPDO &$xpdo A valid xPDO instance.
  * @param string $className Name of the class.
  * @param string|array $graph A related object graph in array or JSON
  * format, e.g. array('relationAlias'=>array('subRelationAlias'=>array()))
  * or {"relationAlias":{"subRelationAlias":{}}}.  Note that the empty arrays
  * are necessary in order for the relation to be recognized.
  * @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.
  */
 public static function loadCollectionGraph(xPDO &$xpdo, $className, $graph, $criteria, $cacheFlag)
 {
     $objCollection = array();
     if ($query = $xpdo->newQuery($className, $criteria, $cacheFlag)) {
         $query = $xpdo->addDerivativeCriteria($className, $query);
         $query->bindGraph($graph);
         $rows = array();
         $fromCache = false;
         $collectionCaching = (int) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
         if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
             $rows = $xpdo->fromCache($query);
             $fromCache = !empty($rows);
         }
         if (!$fromCache) {
             if ($query->prepare()) {
                 $tstart = microtime(true);
                 if ($query->stmt->execute()) {
                     $xpdo->queryTime += microtime(true) - $tstart;
                     $xpdo->executedQueries++;
                     $objCollection = $query->hydrateGraph($query->stmt, $cacheFlag);
                 } else {
                     $xpdo->queryTime += microtime(true) - $tstart;
                     $xpdo->executedQueries++;
                     $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error {$query->stmt->errorCode()} executing query: {$query->sql} - " . print_r($query->stmt->errorInfo(), true));
                 }
             } else {
                 $xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error {$xpdo->errorCode()} preparing statement: {$query->sql} - " . print_r($xpdo->errorInfo(), true));
             }
         } elseif (!empty($rows)) {
             $objCollection = $query->hydrateGraph($rows, $cacheFlag);
         }
     }
     return $objCollection;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:50,代码来源:xpdoobject.class.php

示例3: loadCollectionGraph

 /**
  * Load a collection of xPDOObject instances and a graph of related objects.
  *
  * @static
  * @param xPDO &$xpdo A valid xPDO instance.
  * @param string $className Name of the class.
  * @param string|array $graph A related object graph in array or JSON
  * format, e.g. array('relationAlias'=>array('subRelationAlias'=>array()))
  * or {"relationAlias":{"subRelationAlias":{}}}.  Note that the empty arrays
  * are necessary in order for the relation to be recognized.
  * @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.
  */
 public static function loadCollectionGraph(xPDO &$xpdo, $className, $graph, $criteria, $cacheFlag)
 {
     $objCollection = array();
     if ($query = $xpdo->newQuery($className, $criteria, $cacheFlag)) {
         $query = $xpdo->addDerivativeCriteria($className, $query);
         $query->bindGraph($graph);
         $rows = array();
         $fromCache = false;
         $collectionCaching = (int) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
         if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
             $rows = $xpdo->fromCache($query);
             $fromCache = !empty($rows);
         }
         if (!$fromCache) {
             $stmt = $query->prepare();
             if ($stmt && $stmt->execute()) {
                 $objCollection = $query->hydrateGraph($stmt, $cacheFlag);
             }
         } elseif (!empty($rows)) {
             $objCollection = $query->hydrateGraph($rows, $cacheFlag);
         }
     }
     return $objCollection;
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:40,代码来源:xpdoobject.class.php


注:本文中的xPDO::addDerivativeCriteria方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。