Your SlideShare is downloading. ×
Adodb Pdo Presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Adodb Pdo Presentation

4,091

Published on

Comparison and examples of database abstraction with ADOdb and PDO

Comparison and examples of database abstraction with ADOdb and PDO

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,091
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
66
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PHP: ADOdb or PDO for DB Access Tom Rogers Northwestern University Department of Anesthesiology
  • 2. 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)
  • 3. DB Access/Abstraction Libraries/Classes Available
    • 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 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)
  • 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 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'];
  • 8. 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.
  • 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. Benchmarks http://joseph.randomnetworks.com/archives/2006/04/04/php-database-functions-vs-peardb-vs-adodb/

×