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