本文整理汇总了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;
}