php程序mysql 升级mysqlnd,DB返回字符串而不是int(PHP-7.1 / Laravel的mysqlnd)

To fix it, I installed php5-mysqlnd on my server.

Today, I upgraded my application to the latest php 7.1.*. Everything works correctly, except the bug is back again, i.e. integers in the database are returned as strings, which fails my strict comparison.

I tried to find a package for mysqlnd for php 7.1 but there are none (yet?). But mysqlnd seems enabled though...

phpinfo()

PHP Version => 7.1.3-2+0~20170315222009.20+jessie~1.gbpc7e7dd

System => Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64

mysqlnd

mysqlnd => enabled

Version => mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $

pdo_mysql

PDO Driver for MySQL => enabled

Client API version => mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $

Output on localhost:

"id" => 5

Output on server:

"id" => "5"

1/ Is there something else I should look?

2/ In general, should I refactor my code to accept strings from the db instead of expecting ints?

Thank you.

解决方案

Sigh, I'm dumb! At least I learned something today.

The phpinfo() came from the php version of the console, not Apache.

Turns out php7.1 and mysqlnd was not loaded in Apache.

Everything is fine now...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值