简体   繁体   中英

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?

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.'[[:>:]]"');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM