Monday, May 30, 2011

Re: Pagination Limits

Urghhh. Then use paginate callback (found in Controller::paginate()).

Add this in your model:

public function paginateCount($conditions = array(), $recursive = 0,
$extra = array()) {
if (isset($extra['myHardLimit'])) {
return $extra['myHardLimit'];
}

$parameters = compact('conditions');
if ($recursive != $this->recursive) {
$parameters['recursive'] = $recursive;
}
return $this->find('count', array_merge($parameters, $extra));
}

Use in controller:
$this->paginate(array('myHardLimit'=>300,
'condition'=>'Post.published'=>1....));

I think this should work...

On May 30, 8:50 am, Okalany Daniel <dokala...@gmail.com> wrote:
> Thanks. Its not what i was looking for though. I'm looking for a way to
> limit all the records returned by a pagination. Not to limit the records per
> page.
>
>
>
>
>
>
>
>
>
> On Fri, May 27, 2011 at 8:08 PM, majna <majna...@gmail.com> wrote:
> >http://book.cakephp.org/view/1232/Controller-Setup
>
> > On May 27, 3:20 pm, Okalany Daniel <dokala...@gmail.com> wrote:
> > > How would i set the limit in the model? I couldn't find it.
>
> > > 2011/5/26 Alejandro Gómez Fernández <agom...@gmail.com>
>
> > > > -----BEGIN PGP SIGNED MESSAGE-----
> > > > Hash: SHA1
>
> > > > You want to limit the number of rows the database engine send to cake?
> > > > This limit must be set in the "select" command, so, may be, it must be
> > > > set in the model. Do you try this?
>
> > > > Regards,
>
> > > > Alejandro.
>
> > > > El 26/05/2011 10:11, Okalany Daniel escribió:
> > > > > Hi All,
> > > > > i can't seem to be able to limit the number of records returned from
> > > > cakephp
> > > > > pagination.
>
> > > > > $this->paginate('limit'=>30);
> > > > > limits the number of results per page. But i want to limit the total
> > > > dataset
> > > > > returned. Set it to like 300 since i have a very large table.
>
> > > > > regards,
> > > > > Daniel
>
> > > > -----BEGIN PGP SIGNATURE-----
> > > > Version: GnuPG v1.4.11 (MingW32)
> > > > Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> > > > iQEcBAEBAgAGBQJN3mE/AAoJEHQn9CmeN9DJ3wYH/37cOKjIvWUTuJKkgLrPikNQ
> > > > ZmBmqbdwdksI03FIYTJsh6Q7Ozw8m3/bJx0rUYO0qPvNs2QfyJpzJLSDsZl+ljf2
> > > > Zb6P/vEe4Y8nS8r7zGjavRAzuCbWzJeoPSRNGcsBw2ZnnAGCAUqwSMxElvFl3TC7
> > > > NsNVSiei/tpeuOFrLmZPyGk8/MQqHW+t+4aJDuSoVahsNHR/2WH+9YM9E9NmjdPB
> > > > eqdsrOXrUux7Wbs8EUbJkoh+GRaJGlhOuGd61oDInoSXwuRxOGN2vqap9b7lfaJq
> > > > wlGmCFGx+RiRJ8fT40J2+oVc8Rles/yyFvA0l73ZJksqRfpw0M3GsFnBsK0ME4o=
> > > > =e1Am
> > > > -----END PGP SIGNATURE-----
>
> > > > --
> > > > Our newest site for the community: CakePHP Video Tutorials
> > > >http://tv.cakephp.org
> > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > others with their CakePHP related questions.
>
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscribe@googlegroups.com For more options, visit this
> > group
> > > > athttp://groups.google.com/group/cake-php
>
> > > --
> > > OKALANY DANIEL,
> > > P.O BOX 26150,
> > > Kampala.,
> > > Uganda.http://okasoft.net
> > > --
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php
>
> --
> OKALANY DANIEL,
> P.O BOX 26150,
> Kampala.,
> Uganda.http://okasoft.net
> --

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: