phppostgresqlzend-framework2tablegateway

How to combine lower and like in ZF2?


How to get SQL like this :

select * from foo where LOWER(foo_name) like '%test%'; 

I know that I can achieve this:

select * from foo where LOWER(foo_name) = 'test';

By:

$where->addPredicate(new Predicate\Expression('LOWER(foo_name) = ?', 'test' ));

And this:

 select * from foo where foo_name like '%test%';

By:

$where->addPredicate( new \Zend\Db\Sql\Predicate\Like('LOWER(foo_name)', '%test%'));

But how to combine the two?


Solution

  • Answer given by @dave works fine.

    Even this works -

    $where->expression("LOWER(title) LIKE ?", '%test%');