| 7 pager.inc | public PagerDefault::setCountQuery(SelectQueryInterface $query) |
| 8 pager.inc | public PagerDefault::setCountQuery(SelectInterface $query) |
Specify the count query object to use for this pager.
You will rarely need to specify a count query directly. If not specified, one is generated off of the pager query itself.
Parameters
SelectQueryInterface $query: The count query object. It must return a single row with a single column, which is the total number of records.
File
- includes/
pager.inc, line 106 - Functions to aid in presenting database results as a set of pages.
Code
public function setCountQuery(SelectQueryInterface $query) {
$this->customCountQuery = $query;
}
Login or register to post comments
Comments
For example, we have query:
For example, we have query:
$query = db_select('node, 'n')->extend('PagerDefault')
->limit(10);
// And we want to add custom count query to our pager;
$count_query = db_select('node', 'n');
$count_query->addExpression('COUNT(*)', 'count');
// we can't just type:
$query->setCountQuery($count_query);
// because this func returns nothin and then $query->execute() will cause error;
// so we have to do smth like this:
$tmp = &$query;
$tmp->setCountQuery($count_query);
$query->execute();
// Is it bug, or i'm doing something wrong?
I do not know what you are
I do not know what you are doing exactly, but look at the code at taxonomy_select_nodes(), this might clarify things.