Pregunta

$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?

¿Fue útil?

Solución

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');
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top