Before marking the answer as a duplicate, I would like to say that I have been to this Q&A: Incorrect Integer (2147483647) is inserted into MySQL? and my problems is the other way around. An integer is being returned wrongly by MySQL. As the question before, I'm working with Steam API
and they happen to have really long IDs
.
Here are the following steps that I followed:
Dota2_items
group ( 103582791433341052
) and insert into the DB
. 103582791433341060
GiveawayTasks::where('id', 1)->first()
which translating from Laravel "select * from giveaway_task where id = 1"
Notice the 8 values of difference between the two IDs. It looks like that the database has added 8 values to the initial ID.
To tackle the problem, I did PHP_MAX_INT
which returns 9223372036854776000
. Exactly what I was expecting coming from a 64 bit machine
. Now I tried to subtract the PHP_MAX_INT
and the number from the database to see if the int is bigger than the PHP_MAX_INT
can handle:
PHP_MAX_INT - <Number from the database>
-> 9223372036854776000 - 103582791433341052 = 9119789245421434948
which leads me to the conclusion that I'm not trying to store more in one variable than what PHP_MAX_INT
can handle.
I'm not sure what is going on here since this is beyond my expertise. Any help would be greatly appreciated.
I'm using the Laravel framework, but I don't think that is relevant to the case.
Instead of using Integers
use String
instead for your ids
. You're getting that error because mysql
has a max integer value of 2147483647 for 32-bit
compared to your input 103582791433341052
. It might solve the problem if you treat that integers
as a String
.
You need to use BigInt as opposed to Int for the 'id' column type. See this table for details.
Edit: Strings might be a better alternative as suggested in the comments below.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.