Daniel Lowrey Sun Jun 12 12:15:22 -0400 2011

Subject: 32-bit int casting

Here's a note for people working on 32-bit hardware ...
If you store large integers in your database (greater than 2147483647 -- PHP's max int on 32-bit hardware), php-ar will cast them to (int) when retrieved from the db. This can result in large integer values being set to 2147483647 in your model instead of their actual value. Of course, this is a shortcoming of the PHP language on 32-bit systems and not ActiveRecord itself.

The AR function responsible is ActiveRecord::Column::cast()

If you don't have the option of migrating to 64-bit hardware, you might consider altering that function's "INTEGER" case so that it doesn't use the (int) cast. If you don't mind the regex performance hit you could do something along the lines of:

preg_replace('/\D/', '', $value);

Just something to be aware of if you work with large integers in your model.