I've been around and around with paging. I started using the Containable behavior, which is fantastic for something like 'view', but is highly problematic for listings, especially with pagination. I discovered the Linkable behavior, and it's much more database efficient, and I actually can get it to work with pagination (except when using GROUP BY). I did have to tweak it though, to handle some of the more complex queries that I intend. This checkin includes a bunch of garbage, but given the amount of time I've spent on this crap, I'm afraid to lose anything that might later be useful information. I'll clean up on the next checkin.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@49 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-01 02:36:26 +00:00
parent 9db4dd737d
commit 23a81ae924
5 changed files with 419 additions and 56 deletions

View File

@@ -72,18 +72,5 @@ class Contact extends AppModel {
),
);
// Overriding pagination, since the controller using HABTM joins that
// result in duplicate rows. This may not be the best way to handle
// things (especially if the query return a really large number of rows,
// but it does seem to work.
function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
$conditions[] ="1=1 GROUP BY Contact.id";
return $this->findAll($conditions, $fields, $order, $limit, $page, $recursive);
}
function paginateCount($conditions = null, $recursive = 0) {
$rows = $this->paginate($conditions, null, null, null, null, $recursive);
return count($rows);
}
}
?>