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/sqlrecordset.html', '', '3.145.2.184', 1713961806) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
SqlRecordset and Filters | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

SqlRecordset and 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.

miSqlRecordset reads a collection of records from the database. It supports filters, can sort, group and can join multiple tables.

Get all records:

<?php
$recordset
= new miSqlRecordset('Contacts');
$records = $recordset->getAllRecords();
?>

Using filters:
<?php
$recordset
= new miSqlRecordset('Contacts');
$recordset->addFilter(new miSqlFilterEqual('ContactName', 'John Smith'));
$recordset->getAllRecords();
?>

Join two tables example:
<?php
$recordset
= new miSqlRecordset('Contacts');
$recordset->addJoinCondition('INNER', 'Users', 'ON Users.UserID = Contacts.UserID');
?>

Get the number of records and retrieve the last 10:
<?php
$recordset
= new miSqlRecordset('Contacts');
$numRecords = $recordset->getRecordsCount();
$records = $recordset->getRecordsByIndex($numRecords-10, 10);
?>

Alternative way to retrieve specific records:
<?php
$recordset
= new miSqlRecordset('Contacts');
$recordset->setRecordsLimit(10, 5);  // Retrieve 5 records, starting from 10th
$records = $recordset->getRecords();
?>