Jump to content

Recommended Posts

This package extends the PDO object to provide DB abstraction - a simple way to query different types of databases without needing to change your code.

 

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. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility. - http://php.net/manual/en/intro.pdo.php

 

However PDO does not cover DB query-abstraction - for that you have to use some huge class like ADOdb or PEAR:DB. Which of course will slow your site to a crawl if you are using shared hosting.

 

This class fills this gap and provides DB query-abstraction for common functions like SELECT, REPLACE, INSERT, UPDATE, and DELETE queries. The actual PDO object is not changed in anyway - each of these functions still returns a PDO Statement Object.

 

The total package size is only 18kb! And that is with LOTS of comments explaining the code! It is the missing link for people who love the DATA abstraction PDO provides but also need QUERY abstraction.

 

Currently it only works on SQLite2-3 and MySQL. However because it is built for the SQL language - it will be supper simple to add PostgreSQL or MSSQL support as well (copy mysql class and change 3-5 functions). I just don't have a copy of either DB up and running to test it.

 

http://code.google.com/p/cxpdo/

 

 

I would love it if people would download the package and run index.php which will create a sample SQLite DB and demonstrate how easy this class is to use.  ;)

I would've done away with the PHP4 part a long time ago.  Then again, I'm not a fan of products that are as old as PHP4 is (when compared with newer products, as in this case).  Anyway, gotta do what ya gotta do, even if it does mean PHP4-style x.x.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.