本文整理汇总了PHP中JDatabaseQuery::setLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseQuery::setLimit方法的具体用法?PHP JDatabaseQuery::setLimit怎么用?PHP JDatabaseQuery::setLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDatabaseQuery
的用法示例。
在下文中一共展示了JDatabaseQuery::setLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countItems
/**
* Counts the number of items resulting from a given database query.
*
* @param JDatabaseQuery $query Query whose results should be counted.
*
* @throws Exception
* @return void
*/
public function countItems($query)
{
$cloned = clone $query;
$cloned->clear('select')->select('COUNT(*)');
$this->db->setQuery($cloned);
$count = $this->db->loadResult();
$offset = isset($this->list['offset']) ? $this->list['offset'] : $this->getState()->get('list.' . $this->prefix . '.offset', 0);
$offset = $this->app->input->getInt('limitstart', $offset);
$this->getState()->set('list.' . $this->prefix . 'offset', $offset);
$defaultLimit = $this->app->get('list_limit');
$limit = isset($this->list['limit']) ? $this->list['limit'] : $this->getState()->get('list.' . $this->prefix . '.limit', $defaultLimit);
$this->pagination = new JPagination($count, $offset, $limit, '', $this->app);
if ($query instanceof JDatabaseQueryLimitable) {
$query->setLimit($limit, $offset);
}
}