I have a MySql table whose primary key is a 64bit BigInt
我有一个MySql表,它的主键是64位的BigInt
I'm using Zend_Db (Zend Framework 1.8.4) to insert a new row, then call lastInsertId() to retreive the new row's id, what I get back is a super large number such as 18446744072633694008, and this number changes from time to time, but always this large. the auto increment index is set to 0, and in the database the record actually got inserted with correct primary id, (0, 1, 2...), it's just that the id return from lastInsertId() gives weird number. Is it a known issue for Zend_db, which doesn't deal with 64 bit number?
我使用Zend_Db (Zend Framework 1.8.4)插入一个新行,然后调用lastInsertId()返回新行id,返回的是一个超大号,比如18446744072633694008,这个数字会不时变化,但总是这么大。自动增量索引被设置为0,并且在数据库中实际插入了正确的主id(0,1,2…)的记录,只是来自lastInsertId()的id返回会给出奇怪的数字。这是Zend_db的已知问题吗,它不处理64位数字?
environment: Zend Framework 1.8.4 Apache2 on 32bit box, Ubuntu OS MySQL5.1 PHP5.2.4 MySQL adapter: mysqli
环境:Zend Framework 1.8.4 Apache2在32位框,Ubuntu OS MySQL5.1 PHP5.2.4 MySQL适配器:mysqli。
Thanks
谢谢
2 个解决方案
#1
3
This seems to be a bug in the OO implementation of PHP's Mysqli adapter. See this note on PHP's website.
这似乎是PHP Mysqli适配器的OO实现中的一个错误。请参阅PHP网站上的注释。
For a temporary, stop-gap solution, try using the PDO_Mysql
Zend_Db
adapter.
对于临时的、临时的解决方案,请尝试使用PDO_Mysql Zend_Db适配器。
I'm currently creating an issue and working on a solution to see if I can work around this problem in Zend_Db_Adapter_Mysqli
. I will keep this answer up to date with my progress.
我目前正在创建一个问题并正在研究一个解决方案,看看是否可以在Zend_Db_Adapter_Mysqli中解决这个问题。随着我的进步,我将保持这个答案的最新。
You can follow my progress on a workaround at http://framework.zend.com/issues/browse/ZF-7590
您可以在http://framework.zend.com/issues/browse/ZF-7590上跟踪我的工作进展
#2
1
I developed a lot of Zend_Db
code through ZF 1.0.
我通过ZF 1.0开发了很多Zend_Db代码。
PHP database extensions return PHP strings, not integers. The reason for this is that the RDBMS is likely to be using numeric data types that exceed the range of integers supported in the client PHP binary.
PHP数据库扩展返回PHP字符串,而不是整数。原因是RDBMS可能使用的数字数据类型可能超过客户机PHP二进制文件中支持的整数范围。
Zend_Db
just returns the values it fetches from the PHP database extension, so if you see strange values, then it's probably due to PHP, not Zend_Db
.
Zend_Db只返回从PHP数据库扩展中获取的值,因此如果您看到奇怪的值,那么可能是由于PHP,而不是Zend_Db。
You might want to run the unit tests to test inserts:
您可能想要运行单元测试来测试插入:
$ cd <zf>/tests
$ vi TestConfiguration.php # enable the MySQL adapter you're using
$ phpunit --verbose --filter testAdapterInsert Zend/Db/AllTests.php
One of the assertions made in these tests is that the return value from lastInsertId()
is a PHP string type.
这些测试中的一个断言是,lastInsertId()的返回值是PHP字符串类型。
#1
3
This seems to be a bug in the OO implementation of PHP's Mysqli adapter. See this note on PHP's website.
这似乎是PHP Mysqli适配器的OO实现中的一个错误。请参阅PHP网站上的注释。
For a temporary, stop-gap solution, try using the PDO_Mysql
Zend_Db
adapter.
对于临时的、临时的解决方案,请尝试使用PDO_Mysql Zend_Db适配器。
I'm currently creating an issue and working on a solution to see if I can work around this problem in Zend_Db_Adapter_Mysqli
. I will keep this answer up to date with my progress.
我目前正在创建一个问题并正在研究一个解决方案,看看是否可以在Zend_Db_Adapter_Mysqli中解决这个问题。随着我的进步,我将保持这个答案的最新。
You can follow my progress on a workaround at http://framework.zend.com/issues/browse/ZF-7590
您可以在http://framework.zend.com/issues/browse/ZF-7590上跟踪我的工作进展
#2
1
I developed a lot of Zend_Db
code through ZF 1.0.
我通过ZF 1.0开发了很多Zend_Db代码。
PHP database extensions return PHP strings, not integers. The reason for this is that the RDBMS is likely to be using numeric data types that exceed the range of integers supported in the client PHP binary.
PHP数据库扩展返回PHP字符串,而不是整数。原因是RDBMS可能使用的数字数据类型可能超过客户机PHP二进制文件中支持的整数范围。
Zend_Db
just returns the values it fetches from the PHP database extension, so if you see strange values, then it's probably due to PHP, not Zend_Db
.
Zend_Db只返回从PHP数据库扩展中获取的值,因此如果您看到奇怪的值,那么可能是由于PHP,而不是Zend_Db。
You might want to run the unit tests to test inserts:
您可能想要运行单元测试来测试插入:
$ cd <zf>/tests
$ vi TestConfiguration.php # enable the MySQL adapter you're using
$ phpunit --verbose --filter testAdapterInsert Zend/Db/AllTests.php
One of the assertions made in these tests is that the return value from lastInsertId()
is a PHP string type.
这些测试中的一个断言是,lastInsertId()的返回值是PHP字符串类型。