class MyControllers extends AppController { public $components = array('Paginator'); public function index() { $this->paginate['MyModel'] = array('limit'=>5); print_r($this->paginate('MyModel')); } }
Don't initialize Paginator in the $components section. Just do
class MyControllers extends AppController { public function index() {
$this->paginate = array('MyModel' => array('limit' => 5));
$this->set('data', $this->paginate('MyModel')); } }
The reason is, the $this->paginate settings only get set once, when the Paginate component is loaded, and this will happen automatically when you first call $this->paginate(). If you preload the Paginate component via $components, then you need to also set all your settings at that time, or pass them through with the $this->paginate() call.
Regards
Reuben Helms
On Sunday, 28 April 2013 17:06:03 UTC+10, Cyletech wrote:
Hello all,
I have a model and i want to paginate its data. all i do is, creating a
model, something like this,
and include Paginator component in my controller and use it, something like
this,
And I have a table with "my_controllers" name and it has 10 records. if
everything was fine, the paginator component must give me 5 records for page
one and 5 records for page 2. but it gives me 10 records without any paging.
What is the problem? :(
Thank you
--
View this message in context: http://cakephp.1045679.n5.nabble.com/Paginate-component- fetches-all-data-not-paged- data-tp5714688.html
Sent from the CakePHP mailing list archive at Nabble.com.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment