PHP mysql bigint问题 [英] PHP mysql bigint issue

查看:167
本文介绍了PHP mysql bigint问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个带有bigint的表:

I have two tables with bigint:

table1
id bigint(20) PK autoincrement
name varchar(40),
text

table2
id bigint(20) PK autoincrement
created datetime
text_field
id_table1_ref bigint(20)

将数据插入table1并尝试将table1.id插入table2.id_table1_ref后, 该数字是不同的,即:

After inserting data into table1 and trying to insert table1.id into table2.id_table1_ref, the number is different, i.e.:

table1.t1中的数字1552545662588变为1552545662,甚至更糟的是,变为负数.

Number 1552545662588 from table1.t1 becomes 1552545662, or even worse, a negative number.

我知道这是设置的问题,但是我不知道该如何管理. 我试图为字段设置带符号/无符号的值,但这不起作用.

I know this is an issue with settings, but I can't figure out how to manage this. I tried to set up signed/unasigned values for the fields, but it doesn't work.

这是在我的UNIX本地计算机上发生的,在服务器上一切正常,至少现在是这样.

This is happening on my UNIX local computer, on the server all is working ok, at least for now.

任何帮助将不胜感激.

推荐答案

在将其转换为PHP之前,需要先将其转换为SQL中的字符串.在PHP中,您可以使用 GMP 来处理数字.

You need to CONVERT it to a string in SQL before getting it into PHP. In PHP, you can use GMP to handle the number.

有关转换的MySQL文档: http://dev .mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert

MySQL docs on converting: http://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert

这篇关于PHP mysql bigint问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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