本文整理匯總了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);
}
}