解决mysql pdo查询结果int变成结果string问题

参考资料:

http://stackoverflow.com/questions/1197005/how-to-get-numeric-types-from-mysql-using-pdo#answer-1197041
http://zhangxugg-163-com.iteye.com/blog/1894990
http://dengxi.blog.51cto.com/4804263/1748965
http://blog.ulf-wendel.de/2008/pdo_mysqlnd-the-new-features-of-pdo_mysql/

最近注意到接手的一项目php从mysql取出来的数据都是string类型,无论是主键int id还是float。代码检查没有问题后,感觉可能php配置出了问题。

翻阅相关资料,注意到PDO MySQL驱动配置有误,调整使用mysqlnd驱动即可解决。

yum环境下执行 yum install php73w-mysqlnd(视php版本)。如有冲突,先yum remove php73w-mysql。