By default, when PHP receives data from MySQL, all data is cast as a string - even integers!
You want the MySQL Native Driver for PHP (
Now PHP recognises MySQL data types and will cast them appropriately :)
Install on Ubuntu:
sudo apt-get install php5-mysqlnd.
Install on OS X with Brew:
brew install php5-mysqlnd.