The New "PHP Data Object (PDO)"

Miscellaneous code snippets and examples that members have posted

The New "PHP Data Object (PDO)"

Postby MattM » Mon Dec 11, 2006 5:04 pm

PDO Technical Reference

I developed a database abstraction class based off of our rosterdb class. This class works with the new PDO class built into PHP 5.0 The kicker is, the extension for the class, and the supporting extensions for each type of db you will use must to be enabled in php.ini:

Code: Select all
extension=php_pdo.dll
extension=php_pdo_firebird.dll
extension=php_pdo_informix.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll


A few things I found interesting were:
You can get results in anonymous object form with the column names as the attributes of the object for increased performance and ease of use. Another interesting thing is PDO::prepare
variable binding and Prepared statements woot! :thumright:

Another thing which is really nice is this is natively compatible with (as you can see in the support extensions) most databases!

some other cool stuff PDO supports:

Transactions and auto-commit
stored procedures
3 error handling strategies
"Large Objects (LOBs)"
Last edited by MattM on Wed Dec 13, 2006 10:44 pm, edited 5 times in total.
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA

The New Portable Data Objects

Postby ScratchMonkey » Mon Dec 11, 2006 11:42 pm

PDO looks pretty cool. Good reason to upgrade to PHP5.

I see some places where you return after a throw. In C++ that would be nonsensical, as the return is never reached. What does that mean in PHP?
User avatar
ScratchMonkey
WR.net Expert
WR.net Expert
 
Posts: 212
Joined: Wed Jul 05, 2006 4:32 pm
Location: San Pablo, CA

The New Portable Data Objects

Postby MattM » Tue Dec 12, 2006 12:43 am

ahh yea your right, I'm still pretty noobish :D I'll fix that asap.
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA

Re: The New Portable Data Objects

Postby MattM » Wed Dec 13, 2006 10:52 pm

I now present to [anyone interested], my complete database abstraction layer using PDO.

It's completed:

  • wraps ALL of the existing PDO functions
  • Exception handling
  • Benchmarking
  • SQL query/statement log



It needs some testing if anyone is willing to help me out :thumleft:
Attachments
pdodb.zip
0.2.0
(5.24 KiB) Downloaded 94 times
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA

Re: The New Portable Data Objects

Postby MattM » Thu Dec 14, 2006 4:10 pm

much improved version 0.4.0 :thumleft:
Attachments
pdodb.zip
0.4.0
(5.24 KiB) Downloaded 97 times
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA

Re: The New Portable Data Objects

Postby MattM » Sat Dec 16, 2006 11:10 am

new version
Attachments
pdodb.rar
0.5.0
(3.84 KiB) Downloaded 104 times
Last edited by MattM on Sat Dec 16, 2006 11:11 am, edited 1 time in total.
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA

Re: The New

Postby MattM » Sun Jun 13, 2010 11:40 pm

I have an updated version, a few patches and rare bugs removed i think.
Attachments
pdodb.zip
* version: 0.9.5 04/09/09
(4.11 KiB) Downloaded 90 times
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA


Return to Code Cache

Who is online

Users browsing this forum: No registered users and 0 guests

cron