简体   繁体   English

Zend db adapter mysqli或PDO_MYSQL

[英]Zend db adapter mysqli or PDO_MYSQL

I've seen several code samples that do this in application.ini 我在application.ini中看到了几个代码示例

resources.db.adapter = mysqli

or 

resources.db.adapter = PDO_MYSQL

What is the real difference between the two? 这两者之间真正的区别是什么? Does it impact my code? 它会影响我的代码吗? when should I choose one or the other? 我何时应该选择其中一个?

I developed a lot of the Zend_Db component for Zend Framework through the 1.0 release. 我通过1.0版本为Zend Framework开发了很多Zend_Db组件。 It was the goal that the adapters function identically, or as close to it as could be supported by the PHP extension. 目标是适配器的功能相同,或者与PHP扩展支持的接近。

The same set of unit tests can be run against both MySQL adapters, with virtually no difference. 可以针对两个MySQL适配器运行相同的单元测试集,几乎没有区别。 Performance-wise, there's no measurable difference. 在性能方面,没有可衡量的差异。

The reason you would choose one over the other, and the only reason why we supported Mysqli at all, instead of only PDO_MySQL, is that you need to deploy to a PHP environment where you don't have the PDO extension enabled, and you don't have the privilege to modify the environment. 你选择一个而不是另一个的原因,我们支持Mysqli的唯一原因,而不仅仅是PDO_MySQL,是你需要部署到你没有启用PDO扩展的PHP环境,你不要没有权限修改环境。 For instance, a commodity hosting environment. 例如,商品托管环境。

When you are deploying your application on a web server (shared hosting) using CPANEL, 使用CPANEL在Web服务器(共享主机)上部署应用程序时,

  1. Check that PDO is enabled using phpinfo(); 使用phpinfo();检查PDO是否已启用phpinfo(); . If enabled then you can use resources.db.adapter = PDO_MYSQL 如果启用,则可以使用resources.db.adapter = PDO_MYSQL
  2. If PDO is not enabled the you have to go with the alternative, resources.db.adapter = mysqli . 如果未启用PDO,则必须使用替代resources.db.adapter = mysqli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM