mysqlzend-frameworkzend-framework3zend-db-selectrlike

How to write RLIKE in zend framework 3?


I have a raw query something like:

SELECT * FROM caps WHERE `items` RLIKE '[[:<:]]20003[[:>:]]';

I've converted this query to 'zf3 select' format. I'm using Zend\Db\Sql\Select and extending TableGateway. Here is the converted zf3 query

$this->select(function (Select $s) use ($itemId) {
   $s->where(new Expression(sprintf('(items RLIKE "[[:<:]]`%d`[[:>:]]")', $itemId)));
});

I'm not getting any error when I run the page. But when I print the 'resultSet' the where part is not appending to the query. How can I write this up in zf3?


Solution

  • I have found the solution. I just use expression with my where clause. It's working fine now. Here is the part of my new query.

    $s->where->expression('items RLIKE "[[:<:]]'.$itemId.'[[:>:]]"');