Changes
Title
unchanged
Creating a parameterized LIKE query
Category
unchanged
FAQs
Yii version
unchanged
Tags
unchanged
LIKE, substring query
Content
changed
[...]
$comments = Comments::model()->findAll( $q );
```
Yii will turn this criteria into a LIKE query using `%` wildcards before and after the match variable. By default, it protects active characters in the variable.
One could also use `$q->compare('content', $match, true)` but it has a few side effects. For instance, if `$match` is `"<>hello
"`, the criteria will find the rows where the content is `NOT LIKE '%hello%'
`.
### Warning[...]
While both Postgresql and MySQL include an embedded full-text search, this kind of search is often handled by another service. The most well-known free systems are Xapian, Sphinx and Lucene.
For instance, the [DGSphinxSearch Extension](http://www.yiiframework.com/extension/dgsphinxsearch) shows how to integrate [Sphinx Search](http://sphinxsearch.com/) into Yii.
There are already some yii extensions for this:
- [**Sphinx**](http://sphinxsearch.com/) : [DGSphinxSearch Extension](http://www.yiiframework.com/extension/dgsphinxsearch)
- [**Solr (Lucene)**](http://lucene.apache.org/solr/) : [Solr Extension](http://www.yiiframework.com/extension/solr/)