Doctrine ODM - like operator syntax
Asked Answered
S

1

6

how would i go about simulating the like operator from SQL in doctrine odm?

use case: i want to find a Theme that has somewhere in the field caption string in a variable $search.

How would the query look like?

thanks for all answers

Seismology answered 21/12, 2011 at 12:2 Comment(0)
A
18

use MongoRegex

$qb->field($field)->equals(new \MongoRegex('/.*paliw.*/i'));

source

But i recomed use separate search engine (sphinx, Solr)

Acanthous answered 21/12, 2011 at 12:33 Comment(1)
ok, this works. now i want to search the same variable in other field. i tried adding $qb->field('name')->equals(new \MongoRegex('/.*'.$this->search.'.*/i')); but i get empty results. how to do this?Seismology

© 2022 - 2024 — McMap. All rights reserved.