Published 1 year ago by unitedworx
i have an issue where a Laravel eloquent collection returns an INT as string on live and locally as string! trying to figure out why this difference and make sure that my live and test environments are different.
Anyone come across such issue?
OK, got it: It's a MySQL issue (when using PHP+PDO), one needs to switch mysql to mysqlnd: http://stackoverflow.com/a/20123337/1824374
Edit: Before upgrading to mysqlnd, I used tinker to fetch App\User::find(1); and it was all strings. After the upgrade it worked, but the website was still not working. So i've rebooted my Amazon's EC2 instance and id all worked.
Thanks for the reply, it seems to be a driver issue indeed. I figured out so by tinkering a lot with this and even setting up homestead to figure out the expected behaviour on this.
I even Asked Taylor Orwell about this on Twitter and his response was that this inconsistency is not an eloquent problem but a MySQL driver issue. I recommended mentioning this MySQL driver inconsistency in the framework requirements so that people are aware but not sure if this will happen.
I even contacted mamp pro team ( which I use on my dev box) and they showed some interest in switching to the MySQL native driver in future releases but I am not sure if this is in thier priority list or even at all. It seems that MySQL driver is not something that you can change with a configuration setting but something your stack is compiled with.
Under all this mess I figured it's about time to leave mamp pro behind and use homestead for my development needs. Surely will need some time to get used to but considering I am full into web development with laravel it's wise to follow he recommended development environment practices.