PHP mysql bigint issue

mysql, php

Solution

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 docs on converting: http://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert

Problem

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) ``` After inserting data into table1 and trying to insert table1.id into table2.id_table1_ref, the number is different, i.e.: 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. This is happening on my UNIX local computer, on the server all is working ok, at least for now. Any help would be much appreciated.

Original source