I'm going to start to write a new software with PHP, and I need to know the best way to use database. Should I choose a database class such as Adodb, ezSql etc.
What do you think which class is the best one?
It depends if you need an ORM, or just a database abstraction layer. If you're using Zend Framework
then Zend_Db
is a great choice. Propel ORM is a great ORM for PHP. Doctrine is another great ORM library. On the other hand if you only need an abstraction layer, consider using the built-in PDO, or libraries like PEAR MDB2.
The simplest and lightweight 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;
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With