PHP: ADOdb or PDO for DB Access Tom Rogers Northwestern University Department of Anesthesiology
Definition of Database Access A  database abstraction layer  is an  application programming interface  which unifies the communication between a computer application and  databases  such as  PostgreSQL ,  Oracle  or  SQLite .  (Wikipedia) Database abstraction layers reduce the amount of work by providing a consistent API to the developer and hide the database specifics behind this interface as much as possible.  (Wikipedia)
DB Access/Abstraction Libraries/Classes Available PHP Native Libraries Mysql, Msqli Pgsql Pear:DB Pear:MDB2 ADOdb PDO
ADOdb ADOdb  is a database abstraction library for  PHP  and  Python  based on the same concept as Microsoft's  ActiveX Data Objects . It allows developers to write applications in a fairly consistent way regardless of the underlying database storing the information. The advantage is that the database can be changed without re-writing every call to it in the application. (Wikipedia)
PDO PDO provides a  data-access  abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. (PHP Documentation)
DB Connections ADOdb: include('/path/to/adodb.inc.php'); $ado = NewADOConnection('mysql'); $ado->Connect($server, $user, $pwd, $database); ADOdb(dsn): Include('/path/to/adodb.inc.php'); $ado = NewADOConnection(“mysql://$user:$pwd@$server/$database”); PDO: As of PHP 5.1 no extensions needed, although db driver has to be enabled $pdo = new PDO('mysql:host=localhost;dbname=database',”$user”,”$pwd”);
ADOdb: SQL Query and Iteration $sql = “select pk, description from tbl_demo”; ADOdb: (multi-record dataset) foreach($ado->Execute($sql) as $row){ $pk = $row['pk']; $description = $row['description']; ... process code ... } ADOdb: (single record) $row = $ado->GetRow($sql); $pk = $row['pk']; $description = $row['description'];
PDO: SQL Query and Iteration $sql = “select pk, description from tbl_demo”; PDO: foreach($pdo->query($sql) as $row){ $pk = $row['pk']; $description = $row['description']; ... process code ... } As far as I can tell, there is no PDO equivalent to ADOdb's “GetRow” method.
Functions Available ADOdb  (http://phplens.com/adodb/) Connection Management DB Dictionary Library DB-backed Sessions DB Perform. Monitoring Pagination of Record Sets Blob Handling Transactions String, Date Manipulation Error Handling CSV Export PDO  ( http://us2.php.net/pdo ) Connection Management Prepared Statements/Stored Procedures Large Objects (LOB) Transactions Error Handling
Benchmarks http://joseph.randomnetworks.com/archives/2006/04/04/php-database-functions-vs-peardb-vs-adodb/

Adodb Pdo Presentation

  • 1.
    PHP: ADOdb orPDO for DB Access Tom Rogers Northwestern University Department of Anesthesiology
  • 2.
    Definition of DatabaseAccess A database abstraction layer is an application programming interface which unifies the communication between a computer application and databases such as PostgreSQL , Oracle or SQLite . (Wikipedia) Database abstraction layers reduce the amount of work by providing a consistent API to the developer and hide the database specifics behind this interface as much as possible. (Wikipedia)
  • 3.
    DB Access/Abstraction Libraries/ClassesAvailable PHP Native Libraries Mysql, Msqli Pgsql Pear:DB Pear:MDB2 ADOdb PDO
  • 4.
    ADOdb ADOdb is a database abstraction library for PHP and Python based on the same concept as Microsoft's ActiveX Data Objects . It allows developers to write applications in a fairly consistent way regardless of the underlying database storing the information. The advantage is that the database can be changed without re-writing every call to it in the application. (Wikipedia)
  • 5.
    PDO PDO providesa data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. (PHP Documentation)
  • 6.
    DB Connections ADOdb:include('/path/to/adodb.inc.php'); $ado = NewADOConnection('mysql'); $ado->Connect($server, $user, $pwd, $database); ADOdb(dsn): Include('/path/to/adodb.inc.php'); $ado = NewADOConnection(“mysql://$user:$pwd@$server/$database”); PDO: As of PHP 5.1 no extensions needed, although db driver has to be enabled $pdo = new PDO('mysql:host=localhost;dbname=database',”$user”,”$pwd”);
  • 7.
    ADOdb: SQL Queryand Iteration $sql = “select pk, description from tbl_demo”; ADOdb: (multi-record dataset) foreach($ado->Execute($sql) as $row){ $pk = $row['pk']; $description = $row['description']; ... process code ... } ADOdb: (single record) $row = $ado->GetRow($sql); $pk = $row['pk']; $description = $row['description'];
  • 8.
    PDO: SQL Queryand Iteration $sql = “select pk, description from tbl_demo”; PDO: foreach($pdo->query($sql) as $row){ $pk = $row['pk']; $description = $row['description']; ... process code ... } As far as I can tell, there is no PDO equivalent to ADOdb's “GetRow” method.
  • 9.
    Functions Available ADOdb (http://phplens.com/adodb/) Connection Management DB Dictionary Library DB-backed Sessions DB Perform. Monitoring Pagination of Record Sets Blob Handling Transactions String, Date Manipulation Error Handling CSV Export PDO ( http://us2.php.net/pdo ) Connection Management Prepared Statements/Stored Procedures Large Objects (LOB) Transactions Error Handling
  • 10.