Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
allow skipping count() for big tables - this can be super slow, if no…
Browse files Browse the repository at this point in the history
… count is done, return 10k rows as guess to ensure pagination works
  • Loading branch information
jippi committed May 31, 2014
1 parent db92e2f commit 4af6683
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Controller/AuditsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function admin_index() {
$Instance = ClassRegistry::init($model);

$displayField = $Instance->displayField;
$this->Paginator->settings['do_count'] = empty($Instance->noAuditCount);
$this->Paginator->settings['fields'][] = $model . '.' . $displayField;
$this->Paginator->settings['joins'][] = [
'alias' => $model,
Expand Down
4 changes: 4 additions & 0 deletions Model/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function setupSearchPlugin() {
* @return integer
*/
public function paginateCount($conditions, $recursive, $extra) {
if (empty($extra['do_count'])) {
return 10000;
}

return $this->find('count', compact('conditions'));
}

Expand Down

0 comments on commit 4af6683

Please sign in to comment.