Elliott C. Back: Internet & Technology

PHP MySql Database Class / Library

Posted in Code by Elliott Back on January 10th, 2009.

I was looking for a good out of the box library or class I could use as a singleton to manage database interactions in one of my PHP projects, and after rejecting Pear MDB2, PDO, ADODB and dbFacile I came across just what I was looking for: DbSimple, which satisfies all the requirements I have:

  • Easy to use interface functions
  • Conditional queries, escaped arguments for secure queries and prevention of database injection attacks
  • Error handling, connection management
  • Open source license

It looks daunting at first because the package comes with numerous files, but the usage is quite simple after you upload it; something like this is enough to get started:

require_once('DbSimple/Generic.php');
$DB = DbSimple_Generic::connect("mysql://user:pass@localhost/db");
$DB->query( "DROP TABLE table");

A feature which I probably won’t use as much is the transactionality–you can open, commit, and rollback mysql transactions to bundles your queries together.

This entry was posted on Saturday, January 10th, 2009 at 11:55 pm and is tagged with open source license, interface functions, database interactions, php projects, database class, connection management, adodb, rollback, class library, mysql database, singleton, pear, queries, prevention. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

3 Responses to “PHP MySql Database Class / Library”

  1. mcguillan says:

    Have you ever tried the Zend Framework? It also has a very nice DB handling and some more easy to use features…

  2. [...] PHP MySql Database Class / Library — Elliott C. Back A good out of the box library or class I could use as a singleton to manage database interactions in one of my PHP projects. (tags: php database programming) [...]

  3. Phil says:

    Why did you not like ADODB?

Leave a Reply

Powered by WP Hashcash