The EDB package provides abstraction layers for various DBs. The features of EDB package are as follows:
- Support DBs
- MySQL (require MySQL extension)
- MySQLi (require MySQLi extension)
- SQLite2 (require sqlite2 extension)
- SQLite3 (require sqlite3 extension)
- PostgreSQL (require pgsql extension)
- MSSQL (require mssql extension)
- SQL Relay (require sqlrelay extension)
- Simple and easy to use
- Support bind query. If the DB API does not provide a bind query, it checks only the types of the binded variables.
http://pear.oops.org/docs/EDB/EDB_Common/EDB.html
use pear system
[root@host ~]$ pear channel-discover pear.oops.org
[root@host ~]$ pear install oops/EDB
[root@host ~]$ pear list -a
- PHP myException class
[root@host ~]$ pear install oops/myException
See also https://github.com/OOPS-ORG-PHP/EDB/tree/master/tests
<?php
require_once 'EDB.php';
try {
$db = new EDB (
'mysqli://localhost:/var/run/mysqld/mysql.sock',
'user', 'pwd', 'dbname'
);
$db->set_charset ('utf8'); // only mysql (SET NAMES utf8;)
$rno = $db->query ('SELECT * FROM edb_test WHERE num > ?', 'i', 0);
$r = $db->fetch_all ();
$db->free_result ();
print_r ($r);
} catch ( myException $e ) {
fprintf (STDERR, "%s\n", $e->Message ());
#print_r ($e);
#print_r ($e->Trace ());
#echo $e->TraceAsString () . "\n";
print_r ($e->TraceAsArray ()) . "\n";
$e->finalize ();
}
?>