zend-framework2zend-db-table

\Zend\Db\Sql\Sql where how to add expression?


I have some query when I need to add expresion to WHERE closure. I need this:

(column / ?) % 100 = 0

So I try this:

$where->and->equalTo(new Expression('(column / ?) % 100', $value), 0);

but this return error.


Solution

  • You could use Predicate Expression instead. Try this :

    $where->addPredicate(new Zend\Db\Sql\Predicate\Expression('(column / ?) % 100 = 0',
                            $value));