I'm using php-activerecord
to manage my MySQL entries.
The block of code where the problem ocurs is the following:
$item->id = $result->id;
$item->save();
var_dump($result->id); // string(10) "2386737351"
var_dump($item->id); // int(2147483647)
The problem is that $result->id
is string(10) "2386737351"
like it should, but $item->id
becomes int(2147483647)
. My column id
is of type BIGINT
, so no problem there.
It looks like php-activerecord
converts that value to a int again which is capped at it's maximum value of 2147483647.
Obviously this is terribly wrong and causes Duplicate entry '2147483647' for key 'unique'
.
How can I overcome this?
Your BIGINT is being cast to an int because of the setting in column.php
. While the "real solution" would be to run a 64 bit system, if you cannot, the other thing might be to just stop the cast from happening
Look at line 37 in column.php , I suggest you change that. I haven't tried it myself, but I suppose that this does the trick:
'bigint' => self::STRING,