Laravel在不同操作系统上的问题 [英] Issues with Laravel on different OS

查看:91
本文介绍了Laravel在不同操作系统上的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我在Windows上使用Laravel,PHP 5.5.24,现在我已切换到具有PHP 5.6.11的Ubuntu,并且发生了一些奇怪的事情.

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.

例如:

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

字符串看起来不错,但是在Ubuntu上,所有where子句参数都必须是字符串,例如:

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

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

我不确定这是PHP的问题,MySql还是我的IDE.

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

推荐答案

这与您的MYSQL驱动程序有关.在XAMPP或WAMP的Windows上,它使用Mysql Native驱动程序,该驱动程序从数据库返回记录的本机类型(例如,如果将"id"设置为整数,则它返回"id"的整数).

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).

但是,在Ubuntu上,当您首次安装PHP时,它使用mysql驱动程序代替mysqlnd,后者将整数类型转换为字符串.

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

在这里我问了同样的问题-为什么PHP认为MySQL INT列作为字符串?

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

这篇关于Laravel在不同操作系统上的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆