• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Adodb Pdo Presentation
 

Adodb Pdo Presentation

on

  • 6,374 views

Comparison and examples of database abstraction with ADOdb and PDO

Comparison and examples of database abstraction with ADOdb and PDO

Statistics

Views

Total Views
6,374
Views on SlideShare
6,148
Embed Views
226

Actions

Likes
1
Downloads
63
Comments
0

2 Embeds 226

http://suburbanchicagophp.org 200
http://www.slideshare.net 26

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Adodb Pdo Presentation Adodb Pdo Presentation Presentation Transcript

    • 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/