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


PHP DatabaseFactory::getElementList方法代码示例

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


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

示例1: list

 /**
  * Gets all elements by class
  * @param string $elementClass The element type searched
  * @param string $conditions The conditions string to apply (ex : Region.x < 10 AND World.size = 500)
  * @param string $orderBy The order string to apply (ex : 'Region.x, City.name DESC')
  * @return array The found element list array
  */
 public static function &getElementList($elementClass, $conditions = NULL, $orderBy = NULL, $join = NULL)
 {
     $logInstance = LogTool::getInstance();
     $logInstance->logDebug('Gets ' . $elementClass . ' list (conditions="' . $conditions . '", order="' . $orderBy . '")');
     // Tries to get element list from cache
     if ($join === NULL) {
         try {
             return CacheFactory::getElementList($elementClass, $conditions, $orderBy);
         } catch (ElementFactoryException $e) {
         }
     }
     // Gets element list from database
     list($elementList, $retrievedElementList) = DatabaseFactory::getElementList($elementClass, $conditions, $orderBy, $join);
     // Adds result to cache
     CacheFactory::addElementList($elementClass, $elementList, $conditions, $orderBy);
     if ($join !== NULL) {
         foreach ($retrievedElementList as $mainElementTableName => $mainElementElementList) {
             foreach ($mainElementElementList as $mainElementId => $attachedElementList) {
                 foreach ($attachedElementList as $childElementTableName => $childElementList) {
                     // Builds parent id conditions to cache list
                     $parentIdFieldName = DatabaseFactory::getParentIdColumnName(DatabaseFactory::getElementClassName($mainElementTableName));
                     $childRequestConditions = $childElementTableName . '.' . $parentIdFieldName . '=' . $mainElementId;
                     CacheFactory::addElementList(DatabaseFactory::getElementClassName($childElementTableName), $childElementList, $childRequestConditions, $orderBy);
                 }
             }
         }
     }
     return $elementList;
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:36,代码来源:ElementFactory.class.php


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