0

For example, I was using Laravel on Windows, PHP 5.5.24 and now I have switched to Ubuntu with PHP 5.6.11 and some strange things have happened.

For example:

$spec = $advert->Category->specifications->where('groupid', 2);

String looks fine, but on Ubuntu all where clause parameters must be strings like:

$spec = $advert->Category->specifications->where('groupid', '2');

I'm not sure if it's PHP's fault, or MySql, or even my IDE.

Fabio Antunes
  • 22,251
  • 15
  • 81
  • 96
progr4mer
  • 126
  • 6
  • 1
    Not PHP and not MySQL. Check your IDE formatting settings. – Gino Pane Feb 03 '16 at 10:36
  • 1
    And by the way, have a look at Laravel Homestead (https://laravel.com/docs/5.2/homestead), which was designed especially for Laravel development. – Gino Pane Feb 03 '16 at 10:38

1 Answers1

3

That is to do with your MYSQL driver. On windows on XAMPP or WAMP it uses Mysql Native driver that returns the native types of the records from database (for example it returns integers for 'id' if you set 'id' to be integer).

On Ubuntu however, when you first install PHP it uses mysql driver instead of mysqlnd, which casts integer types to strings.

Here I have asked the same question - Why PHP considers MySQL INT columns as strings?

And here is a nice discussion as well - how do I return integer and numeric columns from MySQL

Community
  • 1
  • 1
naneri
  • 3,771
  • 2
  • 29
  • 53