Question

$select->columns(array('id','state','time'));
$select->where->lessThan('rec', $to)->and->greaterThan('rec', $from);
$select->order('rec ASC');

This is my sql query to get the values based on some range. The result will give me a specific set of rows. I would like to do a mod operation on this.

Like, select * from table where rec mod 5 = 0; which will return every 5th record instead of all the records. How can i do that here?

Was it helpful?

Solution

you need to use Zend\Db\Sql\Predicate\Expression

$select->columns(array('id','state','time'));

$modwhere = new \Zend\Db\Sql\Predicate\Expression('rec mod 5 = 0');
$select->where($modwhere);

$select->order('rec ASC');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top