With this AppModel, any integer column from the database will be casted to a proper int, any time you read it from the database.
Because it's awesome to send data to the client as JSON.
json_encode()
does a great job of encoding your associative arrays in PHP to JSON. But where Javascript (and hence JSON) is picky about types, PHP is more lax. That means you might end up with JSON full of "1234" instead of 1234.
On the serverside, it won't matter, most of the time, since PHP silently cast strings to integers for you. It becomes slightly more annoying when you actually want to use this data on the client, since you will probably need to convert your numeric strings to actual integers manually.
-- "But won't this be awfully slow?", I hear you asking.
You use PHP. You don't care.
The code would throw an error if the field to be checked is a virtualField.
It would be better if a check is performed first to see if the column exists in the $columnTypes array as follows:
Plus further more, the afterFind function needs one more parameter called $primary, this would also throw errors.