Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Useful PHP database class

I am working on a small PHP website. I need a MySql database access class that is easy to configure and work with.

Does not need to be a full framework, I only need a max. few classes.

like image 863
Germstorm Avatar asked Aug 02 '09 11:08

Germstorm


2 Answers

PDO works great for me, even tho it's not a fully blown library like PEAR::MDB2.

PDO is a compiled extension of PHP5, so there's a small performance benefit as well.

like image 200
Lior Cohen Avatar answered Oct 16 '22 20:10

Lior Cohen


ADODb is pretty easy to work with and worth considering. Some illustrative samples:

  //connect
  $dsn = 'mysql://user:pwd@localhost/mydb'; 
  $db = ADONewConnection($dsn);  

  //get a single value     
  $value=$db->GetOne("select foo from bar where x=?", array($x));

  //get a row
  $row=$db->GetRow("select * from bar where x=?", array($x));

  //easy insert example
  $record=array("id"=>1, "foo"=>"bar");
  $db->AutoExecute("table", $record, "INSERT");  
like image 33
Paul Dixon Avatar answered Oct 16 '22 22:10

Paul Dixon