Difference between #4 and #5 of
Creating a parameterized LIKE query

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.
[...]
13 0
21 followers
Viewed: 143 507 times
Version: 1.1
Category: FAQs
Written by: Steve Friedl
Last updated by: Asgaroth
Created on: May 29, 2011
Last updated: 12 years ago
Update Article

Revisions

View all history