最近在服务器上面源码编译PHP和Apache以及Nginx组合测试,然而发现了一些问题。一般现在虚拟主机提供都是5.2、5.3较为前沿一些的提供5.4。自己编译当然越新越好,其中又一次编译configure的参数直接复制了一份过来,没有加上–with-mysql只加了–with-mysqli,以前从来感觉不出这两个的区别,编译出来跑一个phpinfo就以为OK了。结果放了一个网站上去打开一看一直是空白页,还以为编译失败了,害我花了一个多小时重新编译一次。然后测试phpinfo正常,才想到去看error_log,才发现是mysql_connect未定义,而且说的是已经废弃。这才发现原来php5.5.x会提示已经废弃的mysql_connect。然而到php官网找到如下文档。
ext/mysqli PDO_MySQL ext/mysql
PHP version introduced 5.0 5.1 2.0
Included with PHP 5.x Yes Yes Yes
Development status Active Active Maintenance only
Lifecycle Active Active Deprecated
Recommended for new projects Yes Yes No
OOP Interface Yes Yes No
Procedural Interface Yes No Yes
API supports non-blocking, asynchronous queries with mysqlnd Yes No No
Persistent Connections Yes Yes Yes
API supports Charsets Yes Yes Yes
API supports server-side Prepared Statements Yes Yes No
API supports client-side Prepared Statements No Yes No
API supports Stored Procedures Yes Yes No
API supports Multiple Statements Yes Most No
API supports Transactions Yes Yes No
Transactions can be controlled with SQL Yes Yes Yes
Supports all MySQL 5.1+ functionality Yes Most No