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/site@49 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -34,7 +34,93 @@ class UnitsController extends AppController {
|
||||
*/
|
||||
|
||||
function index() {
|
||||
$this->all();
|
||||
//$this->Unit->recursive = 0;
|
||||
|
||||
// $units = $this->Unit->find
|
||||
// ('all',
|
||||
$this->paginate =
|
||||
array(
|
||||
'link' => array
|
||||
('UnitSize' //=> array('fields' => array('name')),
|
||||
//=> array('fields' => true),
|
||||
=> array('fields' => array('name')),
|
||||
//=> array('fields' => array()),
|
||||
//=> array(),
|
||||
|
||||
//'Lease',
|
||||
),
|
||||
'conditions' => array('UnitSize.name =' => "10x30",
|
||||
'UnitSize.id IS NOT NULL'),
|
||||
//'fields' => true
|
||||
'fields' => array('id', 'name', 'status', 'comment')
|
||||
// )
|
||||
);
|
||||
|
||||
$units = $this->paginate();
|
||||
|
||||
|
||||
/* Array */
|
||||
/* ( */
|
||||
/* [joins] => Array */
|
||||
/* ( */
|
||||
/* [0] => Array */
|
||||
/* ( */
|
||||
/* [type] => LEFT */
|
||||
/* [alias] => UnitSize */
|
||||
/* [conditions] => `UnitSize`.`id` = `Unit`.`unit_size_id` */
|
||||
/* [table] => `pmgr_unit_sizes` */
|
||||
/* ) */
|
||||
|
||||
/* ) */
|
||||
|
||||
/* [conditions] => Array */
|
||||
/* ( */
|
||||
/* [UnitSize.name =] => 10x30 */
|
||||
/* [0] => UnitSize.id IS NOT NULL */
|
||||
/* ) */
|
||||
|
||||
/* [fields] => Array */
|
||||
/* ( */
|
||||
/* [0] => id */
|
||||
/* [1] => name */
|
||||
/* [2] => status */
|
||||
/* [3] => comment */
|
||||
/* [4] => `UnitSize`.`name` */
|
||||
/* ) */
|
||||
|
||||
/* [limit] => */
|
||||
/* [offset] => */
|
||||
/* [order] => Array */
|
||||
/* ( */
|
||||
/* [0] => */
|
||||
/* ) */
|
||||
|
||||
/* [page] => 1 */
|
||||
/* [group] => */
|
||||
/* [callbacks] => 1 */
|
||||
/* [link] => Array */
|
||||
/* ( */
|
||||
/* [UnitSize] => Array */
|
||||
/* ( */
|
||||
/* [fields] => Array */
|
||||
/* ( */
|
||||
/* [0] => name */
|
||||
/* ) */
|
||||
|
||||
/* ) */
|
||||
|
||||
/* ) */
|
||||
|
||||
/* [recursive] => -1 */
|
||||
/* ) */
|
||||
|
||||
|
||||
pr($units);
|
||||
$title = 'Index Units';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('units', $units);
|
||||
|
||||
//$this->all();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user