开发者

The best database class or functions for PHP? [closed]

开发者 https://www.devze.com 2023-01-15 00:08 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

开发者_如何学运维

Closed 6 years ago.

Improve this question

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;
?>


I would recommend using PHP's PDO (PHP Data Objects) extension alongside a light-weight database class that extends PDO. You can find this open-source project on Google's Project Hosting at http://code.google.com/p/php-pdo-wrapper-class.


ADOdb. Fast, easy to implement, well documented (not as in read the code to understand) and does nothing you do not want it to do.


An alternative to ADOdb:

https://open-mv.googlecode.com/svn/trunk/

Not much documentation tough at the moment.

0

精彩评论

暂无评论...
验证码 换一张
取 消