简体   繁体   English

使用PDO将整数从64位转换为32位

[英]Integers being converted from 64bit to 32bit with PDO

I am storing 64bit Facebook ids in our mysql database. 我在我们的mysql数据库中存储了64位Facebook ID。 When I view the database table the values are 32bit. 当我查看数据库表时,值是32位。 I am using Laravel, with the PDO connection. 我正在使用带有PDO连接的Laravel。 The values, if dumped out, are correct in the bindings. 如果转储了这些值,则它们在绑定中是正确的。 Once executed they are different in the DB. 一旦执行,它们在数据库中将有所不同。 I have tried changing database from MariaDB to MySQL to see if it was the database causing it. 我尝试将数据库从MariaDB更改为MySQL,以查看是否是引起它的数据库。 Everything points to it being PDO. 一切都表明它是PDO。

This does not happen on my local development machine which is using the exact same version of PHP 7.0.15 . 在使用完全相同版本的PHP 7.0.15本地开发计算机上,不会发生这种情况。 I get no errors on either development or local. 我在开发或本地方面都没有错误。

MySQL and PHP are 64bit versions. MySQL和PHP是64位版本。 I have not been able to find anything that helps me resolve the issue. 我找不到能帮助我解决问题的任何东西。

I found this bug report from 2013 that clearly illustrates my issue but seems to have been resolved. 我发现2013年的此错误报告清楚地说明了我的问题,但似乎已解决。

In Laravel's Connection class the bindValues method is checking the data type like so. 在Laravel的Connection类中, bindValues方法像这样检查数据类型。

public function bindValues($statement, $bindings)
{
    foreach ($bindings as $key => $value) {
        dump($value); // Value is correct at this point.
        $statement->bindValue(
            is_string($key) ? $key : $key + 1, $value,
            is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR
        );
    }
}

I have also tried setting the third param to just be PDO::PARAM_STR but that didn't change the behavior. 我也尝试将第三个参数设置为PDO::PARAM_STR但这并没有改变行为。

The server is CentOS Linux 7.3.1611 , MySQL is 5.7.17 , PHP 7.0.15 服务器是CentOS Linux 7.3.1611 ,MySQL是5.7.17 ,PHP 7.0.15

PDO and MySql Extensions PDO和MySql扩展

php70w-pdo.x86_64                   7.0.15-1.w7 @webtatic
php70w-mysql.x86_64                 7.0.15-1.w7 @webtatic

The table is InnoDB with UTF-8 Unicode encoding and the collation is utf8_unicode_ci 该表是具有UTF-8 Unicode编码的InnoDB ,排序规则是utf8_unicode_ci

The sql connection is: sql连接为:

'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'modes' => ['STRICT_TRANS_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','ERROR_FOR_DIVISION_BY_ZERO','NO_AUTO_CREATE_USER','NO_ENGINE_SUBSTITUTION'],
'engine' => null,

What things can I try to resolve my issue? 我可以尝试解决什么问题?

I found the solution. 我找到了解决方案。 Our server was using the regular php70-mysql drivers and not the native drivers php70-mysqlnd . 我们的服务器使用的是常规php70-mysql驱动程序,而不是本机驱动程序php70-mysqlnd Once we updated that the integers were preserved. 一旦我们更新了整数就被保留了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 64 位数字转换为 32 位数字 - Convert from 64bit number to 32bit number 如何在PHP中将两个无符号的32位整数合并为64位整数? - how to combine two unsigned 32bit integers to 64bit integer in php? 将64位整数截断为32位并模拟值 - Truncate 64Bit Integer to 32Bit and simulate value SSH2 dll未加载-Windows Server 2008 64位,PHP 5.3.5 32位,Apache 32位 - SSH2 dll not being loaded - windows server 2008 64bit, php 5.3.5 32bit, apache 32 bit 如何将float转换为64bit二进制或将32bit float转换为64bit int-PHP - how convert float to 64bit binary or 32bit float to 64bit int - php 在WAMP 64位上将64位PHP转换为32位 - Convert 64bit PHP to 32bit on WAMP 64bit 在同一服务器上使用带有64位oracle客户端的php 7.3.4 64bit和带有32位oracle客户端的php 7.3.4 32bit - Using php 7.3.4 64bit with a 64bit oracle client and php 7.3.4 32bit with a 32bit oracle client on the same server 使用PHP计算32位系统上的按位64位运算 - Calculate bitwise 64bit operations on 32bit system with PHP 32位和64位ODBC驱动程序与PHP配合使用 - 32bit and 64bit ODBC Drivers playing nice with PHP 32 位系统上的密码散列然后迁移到 64 位系统 - Password hashing on 32bit system then migrating to 64bit systems
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM