Replacement for PEAR: MDB2 on PHP 5.3

孤者浪人 提交于 2019-11-30 02:45:37

问题


I've been using pear packages in php for years. I'm in the process of upgrading/moving a sites that uses the MDB2 pear package and it has not been updated for PHP 5.3.X.

In 5.3, MDB2 is returning those new annoying errors.

Unknown: Assigning the return value of new by reference is deprecated in /usr/local/lib/php/MDB2.php on line 390

I know I can change my error reporting settings to get rid of them, but I'd rather not make any exceptions. Anyway, Is anyone else using MDB2 these days and have a solution? Are there similar database packages you recommend?


回答1:


I would definitly go for an ORM, at least if you are working on a big project, for which you don't want to use mysqli_* or PDO functions/methods directly -- Doctrine being the most developped/used, nowadays (It's the default ORM of the symfony Framework, and can be integrated in Zend Framework quite easily).

About the E_DEPRECATED errors, though : PHP 5.3 is quite young, and lots of libraries/software/projects have not been adapted yet -- you'll probably have lots of those in the next couple of months :-(




回答2:


You can also upgrade to the beta 3 version via the command line

pear upgrade MDB2-beta
pear upgrade MDB2_Driver_Mysql-beta

Explanation of why current stable version isn't compliant with strict error reporting: http://pear.php.net/bugs/bug.php?id=9756

Source for the command:
http://pear.php.net/bugs/bug.php?id=18050




回答3:


I'm going to comment on this, since it's coming up high on Google search results for the problem.

I contacted the lead developer for MDB2, who said:

please check out a copy of MDB2 from SVN, it's fully PHP5.3 compatible, with many performance improvements. I'm currently waiting for some fixes to the new SQL Server driver (Microsoft is working on it this very week), then I'll push a new stable release.

(Edit, 4 years later: This is no longer right, do not do this)




回答4:


I just went and downloaded the latest version of MDB2 (MDB2-2.5.0b3) from here http://pear.php.net/package/MDB2/download and it has got rid of all my errors. Seems to work fine with PHP Version 5.3.5




回答5:


You can use Zend Framework database support or use an ORM like Doctrine or Propel




回答6:


I got around all the deprecated errors and warnings, using MDB2 and PHP 5.3, but I've gotten some really weird errors on MDB2, so wondering what's up under the hood. My environment is CentOS, PHP 5.3, MDB2-2.4.1, MySQL 5.0.77

Anytime, I use autoExecute 2x in a php file, the 2nd is failing (same goes if I try to use prepare and then execute). I've been logging to my MySQL query log, and while a successful INSERT will show the values, a failed INSERT will always have only the placeholders. ie: values(?, ?, ?, ?). And the MDB2_Error will always mention RECURSION

lastInsertID() never worked with MySQL tables and autoincrement fields (with mysqli driver) I did enough debugging on it, going deep into the call stack, and the result get's so wrapped up in Objects, that you can't tell what it is, until the very end. I'd love to be using MDB2 more, but in fact, I've had to revert back to straight mysql, numerous times because of these issues. Maybe Lucas or other developers might shed some light on this subject, or point us in the right direction.




回答7:


If you only use MDB2 for MySQL, you can replace it and keep majority of the functions with MDBDid: http://azure-dev.kiao.net/648-mdb2 You will only have little code to adapt.



来源:https://stackoverflow.com/questions/1530112/replacement-for-pear-mdb2-on-php-5-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!