Creating a parameterized LIKE query

Comparing #4 with #5

Revision #5 was created by François Gannaz François Gannaz on Jun 2, 2011, 7:32:54 PM.

(m)

Content

[...]
$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.
[...]