所以我有一个查询,在我的生产安装中,需要在'where'方法中引用"id",否则不返回结果。在我的本地安装中,情况正好相反。如果我使用的是引号,它就不起作用了。
生产
'invoices' => Auth::user()->invoices->where('paid', "0")
本地主机
'invoices' => Auth::user()->invoices->where('paid', 0)
这真的很奇怪,每当我从github部署时,我真的不想进去更改它。这是一个常见的问题吗?我似乎找不到任何关于它的信息。
我将列出一些Laravel查询日志:
本地安装,报价围绕int(不起作用)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 10.49
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 1.39
)
)
本地安装没有报价围绕int(工作)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 0.84
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 1.15
)
)
生产安装没有报价围绕int(不工作)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 2.3
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 0.67
)
)
生产安装,报价围绕int(工作)
Array (
[0] => Array (
[query] => select * from `users` where `users`.`id` = ? limit 1
[bindings] => Array (
[0] => 1
)
[time] => 0.88
)
[1] => Array (
[query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
[bindings] => Array (
[0] => 1
)
[time] => 0.81
)
)
解决方案:
事实证明,我的服务器上没有mysqlnd作为活动驱动程序。激活它解决了问题。
事实证明,我的服务器上没有mysqlnd作为活动驱动程序。激活它解决了问题。我用以下命令做到了这一点:
yum remove php-mysql
yum install php-mysqlnd
php -m | grep mysqlnd