0

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.

James
  • 5,137
  • 5
  • 40
  • 80
  • Is this problem only with Laravel or generally in PHP when you are using MAMP? What's code for testing you use? Is it simple `false === false` or something else? – Marcin Nabiałek Jun 09 '14 at 14:57
  • @MarcinNabiałek doing a quick test, it seems that `$i = 0; echo $i === 0 ? "True" : "False";` actually works as expected. However, some of my Laravel models return custom attributes as integers, but a triple equals check isn't catching them. – James Jun 09 '14 at 15:04
  • Narrowing it down, it could be related to this; http://stackoverflow.com/questions/21961870/laravel-returns-json-string-on-local-machine-but-integer-on-elastic-beanstalk-in – James Jun 09 '14 at 15:05

1 Answers1

0

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.

Community
  • 1
  • 1
James
  • 5,137
  • 5
  • 40
  • 80
  • 1
    Hey @deceze I've added some more information, sorry about that. – James Feb 12 '15 at 12:05
  • The problem is that MAMP does NOT come with mysqlnd as of March 2015, but still uses the obsolete libmysql driver (http://dev.mysql.com/downloads/connector/php-mysqlnd/). pdo_mysql is an API that you can use to talk to the mysqlnd driver. – Kai Pommerenke Mar 06 '15 at 01:17