Notice: Undefined offset: 8192 in /home/miphpf/domains/ on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/ on line 506
Sql Filters | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.

Sql Filters

: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/ on line 291.

The sql filters are used with miSqlRecordset to filter the set of records to be retrieved.

Records can be matched with one of the built-in filters or a custom filter. Specialized filter can be created through subclassing one of the bult-in filters.

The built-in filter matches records where:
miSqlFilterSubstring - field contains a string
miSqlFilterStarts - field starts with a string
miSqlFilterEnds - field ends a string
miSqlFilterEqual - field is equal to a value
miSqlFilterNotEqual - field is not equal to a value
miSqlFilterBiggerThan - field is bigger than a value
miSqlFilterBiggerOrEqual - field is bigger than or equal to a value
miSqlFilterSmallerThan - field is smaller than a value
miSqlFilterSmallerOrEqual - field is smaller than or equal to a value
miSqlFilterRegExp - field matches a regular expression
miSqlFilterIn - field is one of the values
miSqlFilterNotIn - field is not one of the values

miSqlFilterCustom  - Matches records using custom sql.

The usage of filters is quite straightforward as can be seen in the following examples:

= new miSqlRecordset('Products');
$recordset->addFilter(new miSqlFilterEqual('CategoryID', $categoryId));
= array(2, 4, 8);
$recordset = new miSqlRecordset('Products');
$recordset->addFilter(new miSqlFilterIn('ProductID', $products));
= new miSqlRecordset('Products');
$recordset->addFilter(new miSqlFilterIn('ProductID', '2,4,8'));
= new miSqlRecordset('Users');
$recordset->addFilter(new miSqlFilterCustom('UserType', "UserType = 'Manufacturer' OR UserType = 'Supplier'"));