Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 506

Warning: Incorrect key file for table './miphpf_miphpfcom/watchdog.MYI'; try to repair it query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.', 2, '', 'http://www.miphpf.com/manual/sqlfilters.html', '', '44.192.53.34', 1711646906) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Sql Filters | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Sql Filters

: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc 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:

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