Does anybody knows how can I force a field as a biginteger to avoid Int overflow in Cake 3
In my MySQL 5.7.x database i have a BIGINT(11) Unsigned field, but cake is mapping it as an int and i want to keep it as a bigint
I partially solved this changing my Wamp x86 to x64 with PHP 7 to force integer values to have a higher capacity
You’ll need to use a 64bit build of PHP to ensure integers don’t overflow in PHP. As for schema definition, you can use the bigint type in your fixtures and migrations.
Yes, I installed a PHP 7.1 x64 to solve this. I am using WAMP. I don’t understand why Cake parsed to Int if my database field is BIGINT
PHP doesn’t have a ‘bigint’ type it only has integer, so that’s why we use it. You could map bigints to strings which would be OK until you need to do any math on them or insert them back into the database (as integer columns get bound as integers). Consistently mapping bigint to PHP ints helps expose incorrect server configurations earlier.
bigint could be mapped as float or double that have bigger capacity - http://php.net/manual/pt_BR/language.types.integer.php
We could do that. But we would likely still run into issues when binding those values into SQL queries later on as the PHP docs point out that casting floats to integers is limited by php_max_int.