views:

39

answers:

2

Hi all,

I am using cakephp 1.26.
I am doing some self-learning about Pagination in CakePHP.

I have tested the following code in my localhost, and it works fine.
I have altered a little change to the second line of code, and found that nothing change to the result.

1st version:

$this->paginate=array('conditions'=>array('Testing.zero'=>'0'), 'limit' => 3);
$w = $this->paginate(); 
$this->set('postVariable', $w);

2nd version:

$this->paginate=array('conditions'=>array('Testing.zero'=>'0'), 'limit' => 3);
$w = $this->paginate('Testing'); 
$this->set('postVariable', $w);

3rd version:

$this->paginate=array('conditions'=>array('Testing.zero'=>'0'), 'limit' => 3);
$w = $this->paginate('helloworld'); 
$this->set('postVariable', $w);

4th version:

$this->paginate=array('conditions'=>array('Testing.zero'=>'0'), 'limit' => 3);
$w = $this->paginate($this->helloworld); 
$this->set('postVariable', $w);

I have no idea what I should input into the brackets of $this->paginate()

+1  A: 

The paginate function can be found in /cake/libs/controller/controller.php,line 934.It's a bit long but not that complex.And I think you can read it and find the reason yourself.Personally I prefer current model name as the parameter.In your code ,that would be

$w = $this->paginate("Testing"); 
SpawnCxy
+3  A: 

The documentation says it all: http://api.cakephp.org/class/controller#method-Controllerpaginate

First parameter is the model name, second parameter is a scope, that is, an additional conditions array. Third parameter is currently useless.

sibidiba
Also, here's a link to the Cookbook which describes this feature: http://book.cakephp.org/view/165/Controller-Setup
Michael