Revision #5 has been created by François Gannaz on Jun 2, 2011, 7:32:54 PM with the memo:
(m)
« previous (#4) next (#6) »
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
The pattern `LIKE '%XXX%'` must not be abused.[...]