本文整理匯總了PHP中DataList::setDataModel方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataList::setDataModel方法的具體用法?PHP DataList::setDataModel怎麽用?PHP DataList::setDataModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataList
的用法示例。
在下文中一共展示了DataList::setDataModel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Aggregate
/**
* @deprecated 3.0 Use DataList::create and DataList to do your querying
*/
public function Aggregate($class = null)
{
Deprecation::notice('3.0', 'Call aggregate methods on a DataList directly instead. In templates ' . 'an example of the new syntax is <% cached List(Member).max(LastEdited) %> instead (check partial-caching.md documentation ' . 'for more details.)');
if ($class) {
$list = new DataList($class);
$list->setDataModel(DataModel::inst());
} else {
if (isset($this)) {
$list = new DataList(get_class($this));
$list->setDataModel($this->model);
} else {
throw new InvalidArgumentException("DataObject::aggregate() must be called as an instance method or passed a classname");
}
}
return $list;
}
示例2: getDataList
/**
* This allows templates to create a new `DataList` from a known
* DataObject class name, and call methods such as aggregates.
*
* The common use case is for partial caching:
* <code>
* <% cached List(Member).max(LastEdited) %>
* loop members here
* <% end_cached %>
* </code>
*
* @return DataList
*/
public static function getDataList($className)
{
$list = new DataList($className);
$list->setDataModel(DataModel::inst());
return $list;
}