DBI for PHP/MySQL
DBI is a database abstraction interface for PHP and MySQL. It provides a method for using prepared statements for SQL queries. The interface is similar to that of Perl::DBI. A sample of its usage would be as follows:
<?
include('dbi.class.php');
$db = new dbi();
$db->connect('host', 'username', 'password', 'database');
$rs = $db->prepare('SELECT * FROM customers WHERE lastname = ?');
$rs->execute('Smith');
while ($row = $rs->fetch_array()) {
// Do something with the row
}
?>
This interface is most useful for environments where prepared statements are desired and a more standard solution, such as the mysql_i functions or PEAR::DB, is not available.