Search code examples
phpmacosmampmamp-pro

MAMP PHP - Equality Condition Weirdness


I'm using MAMP PRO 3, with PHP 5.5.10 (in CGI mode, although this same bug occurs when using the module) as my development server on OSX Mavericks.

My existing codebase written using the Laravel framework is acting oddly now that I'm using MAMP. Any condition where I use a triple equals (for strict checking) is returning as FALSE. This is weird because if I use the default PHP install that comes with OSX (or the php55 version from Homebrew) all of my code works fine.

I can't see any reason this would occur because my code has always worked perfectly before.


Solution

  • The reason for this is the driver that MAMP uses; mysqlnd (MySQL Native Driver). It seems not to know about the type of a field and insteads casts everything as a string.

    Setting up the pdo_mysql driver instead, makes it work.

    PHP + PDO + MySQL: how do I return integer and numeric columns from MySQL as integers and numerics in PHP? has more information.