After graduation from calling the mysql_* functions directly during my code, I have walked up to and including home-made database abstraction class. Now, I am starting to believe that I ought to really make use of a "professional" DB class rather.

I understand you will find many of them available (ADODB, PDO, MDB2, etc) but I wish to know which I ought to check out. What do you experience feeling is the greatest one and why?

I like PDO for my database access layer for an additional reasons:

  • Object-Oriented
  • Supports Named Parameters
  • Area of the PHP Core by 5.1. (thx to R. Bemrose for pointing this out)
  • Could be fairly easily extended to aid custom features

Nevertheless, I'm searching at going from the own custom wrapper for PDO that delivers dynamic querying, simplified functions and so on to some full-fledged framework. I like the Zend Framework and something benefit that Yes, it offers is you can use either MySQLi or PDO with support for named parameters (something you do not get using the core mysqli library).

I'll point out that though I initially began with using MySQLi, I needed to change to PDO because MySQLi had difficulties with large blobs. I'm not sure in the event that's still the situation or otherwise though.

I personally use Zend_Db extensively, and that i enjoy it for many reasons -

  1. The Zend_Db package is all-in-one and may be used with no entire Zend Framework library
  2. It really works with lots of database brands, so my code simply works even if PDO isn't present
  3. It produces prepared claims even without use of a PDO wrapper
  4. It offers the building blocks for additional Zend_Db modules which are outsides the scope of PDO and that we use extensively (Zend_Db_Choose, Zend_Db_Table, Zend_Db_Profiler and much more)
  5. The origin will come in PHP, which causes it to be super easy to search through it to determine how situations are done

The easiest and light-weight db class is

http://code.google.com/p/edb-php-class/

<?php
$result = $db->q("select * from `users`limit 3");

foreach($result as $a){
        $a = (object) $a;
        echo $a->id.' '.$a->name.' '.$a->url.' '.$a->img.'</br>';
}


$result = $db->line("select * from `users` where id = '300' limit 1");
echo $result['name']; 
echo $result['surname']; 



$name = $db->one("select name from `ilike_pics` where id = '300' limit 1");
echo $name;
?>

I suggest you have a look at Jeremy Zawodny's Database Abstraction Layers Must Die!

So -- don't use a database abstraction layer whatsoever!