djDBI - A PHP Database Interface
A PHP class I've written for quick and universal MySQL, MSSQL and SQLite3 database handling. I've used it extensively and with small variations it has worked well for both easy DB management as well as debugging.
USAGE * The public methods open() and query() will exit the PHP script * with error messages if a connection cannot be established and/or * if a query returns FALSE. query() will return an associative row * array if a resultset with content was returned, NULL if it's * empty. For other successful SQL statements like INSERT, UPDATE, * DELETE, DROP, etc, query() will return TRUE on success. For SQLite * you just need the $database as a file and $type parameters. * * Example of usage: include 'djDBI.php'; $db = new djDBI(); $db->open('localhost', 'database', 'user', 'pass', 'MYSQL'); $result = $db->query("SELECT * FROM testdata"); $db->close(); unset($db); if (!is_null($result)) // Returned an associative array you can loop through.
Updated 2014 for MySQLi
Updated 2018 for SQLite3
- SQLite3 may need the db file(s) and its folder(s) to be fully writeable by the webserver user to work because of journaling mechanics. I'll advice to place SQLite3 database files in their own isolated folders if doing it this way.
- SQLiteStudio is a nice portable editor for SQLite.