In my query using Symfony 1.4/Propel 1.4, for pagination purpose, I need to set limit like
Page1: LIMIT 0,6
Page2: LIMIT 6,6
Page3: LIMIT 12,6
.... & so on
I try
$c->setLimit(6);
Which is generating
LIMIT 6
I didn't find setLimit methods with two parameters or similar function to set starting limit too. This is very common operation & I'm sure must be available in Propel but I'm unable to figure it out till now.
Can someone please suggest how set required limit (LIMIT 0,6)
You should use limit()
and offset()
, described here.
For
LIMIT 12,6
use (if you are using the 1.6 ModelCriteria)
$c->limit(6);
$c->offset(12);
and if you use old criteria:
$c->setLimit(12);
$c->setOffset(12);
By the way, why do you build your own pager? Symfony profive a sfPager (generic) and also a sfPropelPager which handle that pretty well (even if you use a custom criteria, you can defined it using setCriteria()
).