问题描述
前几天,。
要修复它,我在我的服务器上安装了php5-mysqlnd。
To fix it, I installed php5-mysqlnd on my server.
今天,我将应用程序升级到最新的php 7.1。*。一切正常,除了bug再次出现,即数据库中的整数作为字符串返回,这无法严格比较。
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.
我试图找到一个用于mysqlnd的包对于php 7.1,但没有(但?)。但是mysqlnd似乎启用了...
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 $
localhost上的输出:
Output on localhost:
服务器上的输出:
1 /还有其他东西我应该看吗?
1/ Is there something else I should look?
2 /一般来说,我应该重构我的代码来接受字符串从db而不是期待ints?
2/ In general, should I refactor my code to accept strings from the db instead of expecting ints?
谢谢。
推荐答案
Sigh, I'm dumb! At least I learned something today.
phpinfo()来自控制台的php版本而不是Apache。
导致php7.1和mysqlnd未在Apache中加载。
The phpinfo() came from the php version of the console, not Apache.Turns out php7.1 and mysqlnd was not loaded in Apache.
一切都很好...
这篇关于DB返回字符串而不是int(PHP-7.1 / Laravel的mysqlnd)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!