Difference between #4 and #5 of
Using filters with CGridView and CArrayDataProvider

Revision #5 has been created by Kostas Apazidis (KonApaz) on Oct 18, 2013, 11:45:54 AM with the memo:

full comparisons
« previous (#4) next (#6) »

Changes

Title unchanged

Using filters with CGridView and CArrayDataProvider

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

CGridview, CArrayDataProvider, filters, filter

Content changed

[...]
}

}
```

(By @KonApaz)
 
If you want to apply full comparisons (>, <, >=, <=, =) use this
 
 
 
```php 
if (substr($searchValue, 0, 2) == '<=') {
 
    if (substr($searchValue, 2) < $compareValue) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if (substr($searchValue, 0, 2) == '>=') {
 
    if (substr($searchValue, 2) > $compareValue) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if ($searchValue[0] == '<') {
 
    if (substr($searchValue, 1) <= $compareValue) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if ($searchValue[0] == '>') {
 
    if (substr($searchValue, 1) >= $compareValue) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if (stripos($compareValue, $searchValue) === false) {
 
    unset($data[$rowIndex]);
 
}
 
```
 
 
 
Controller
----------

```php
// Create filter model and set properties
$filtersForm=new FiltersForm;
[...]
19 0
29 followers
Viewed: 92 838 times
Version: 1.1
Category: How-tos
Written by: marcovtwout
Last updated by: yugene
Created on: Sep 12, 2011
Last updated: 10 years ago
Update Article

Revisions

View all history