php pdo emulate_prepares false stringify_fetches false int仍然是字符串 [英] php pdo emulate_prepares false stringify_fetches false int still string

查看:147
本文介绍了php pdo emulate_prepares false stringify_fetches false int仍然是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从托管在 Hostgator 上的站点上的MySQL数据库中获取数据时输出数字. PHP 7.0,MySQL-服务器版本:5.5.48-37.8-Percona服务器(GPL),版本37.8,修订版727,数据库客户端版本:libmysql-5.1.73.

I am trying to get numbers to output as such when fetching data from a MySQL database on a site hosted on Hostgator. PHP 7.0, MySQL - Server version: 5.5.48-37.8 - Percona Server (GPL), Release 37.8, Revision 727, Database client version: libmysql - 5.1.73.

PDO参数:

[
    PDO::ATTR_EMULATE_PREPARES => false,
    PDO::ATTR_STRINGIFY_FETCHES => false,
]

即使具有这些属性,它仍然会返回整数作为字符串. 我该如何解决?

Yet even with these attributes, it still returns integers as strings. How can I fix this?

推荐答案

您是否看过以下问题:

Have you looked at this SO question: How to get numeric types from MySQL using PDO? Also, make sure you have mysqlnd installed and activated. Look at php --info under pdo_mysql.

如果是,则输出应如下所示:

If it is, the output should look like this:

pdo_mysql

PDO Driver for MySQL => enabled
Client API version => mysqlnd 5.0.10 - 20111026 - $Id:___ $

如果尚未安装,请使用以下命令进行安装:

If that isn't installed, install it with this:

apt-get remove php5-mysql
apt-get install php5-mysqlnd
service apache2 restart

如果不能解决问题,则可能是您未向我们展示的代码中的问题.

If that doesn't fix it, the issue is likely in the code you haven't shown us.

希望这会有所帮助! 干杯!

Hope this helps! Cheers!

这篇关于php pdo emulate_prepares false stringify_fetches false int仍然是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆