0

我正在使用 cakephp 1.26。
我正在对 CakePHP 中的分页进行一些自学。

我已经在我的本地主机中测试了以下代码,它工作正常。
我对第二行代码做了一点改动,发现结果没有任何变化。

第一个版本:

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

第二版:

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

第三版:

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

第 4 个版本:

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

我不知道应该在 $this->paginate() 的括号中输入什么

4

2 回答 2

3

文档说明了一切:http ://api.cakephp.org/class/controller#method-Controllerpaginate

第一个参数是模型名称,第二个参数是范围,即附加条件数组。第三个参数目前没用。

于 2010-07-07T15:03:35.280 回答
1

paginate函数可以在/cake/libs/controller/controller.php第 934 行找到。它有点长,但并不复杂。我想你可以自己阅读并找到原因。我个人更喜欢当前模型名称作为参数。在你的代码中,那将是

$w = $this->paginate("Testing"); 
于 2010-07-07T08:59:43.853 回答