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/sqlrecord.html', '', '18.218.231.141', 1734789889) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Using miSqlRecord | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Using miSqlRecord

: 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.

miSqlRecord is an active record class. It can be used to read, insert, update and delete a specific record from the database. When reading if the record cannot be found in the database, miDBException will be thrown.

* Reading a record by primary key example:

<?php
try 
{
   
$sqlRecord = new miSqlRecord('Contacts', 'ContactID');
   
$sqlRecord->readPK($id);
}
catch (miDBException $exception)
{
   
// Error handling here ...
}
?>

* Reading a record by any key example:
<?php
$sqlRecord
= new miSqlRecord('Contacts', 'ContactID');
$sqlRecord->read($key, $value);
?>

* Inserting new record example:
<?php
$sqlRecord
= new miSqlRecord('Contacts', 'ContactID');
$sqlRecord->set('ContactName', 'some test name');
$id = $sqlRecord->insert();
?>
If the table has "auto increment" key, the newly created id is returned by the insert method.

* Updating a record example:

<?php
$sqlRecord
= new miSqlRecord('Contacts', 'ContactID');
$sqlRecord->readPK($id);
$sqlRecord->set('ContactName', 'some test name');
$sqlRecord->update();
?>

* Deleting a record example:
<?php
$sqlRecord
= new miSqlRecord('Contacts', 'ContactID');
$sqlRecord->set('ContactID', '10');  // or read() the record from the DB
$sqlRecord->delete();
?>