gpt4 book ai didi

php - Eloquent 模型中 id 周围的引号在生产站点上是必需的,但在本地主机上不起作用

转载 作者:可可西里 更新时间:2023-11-01 06:38:44 25 4
gpt4 key购买 nike

所以我有一个查询,在我的生产安装中需要在“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
)
)

带有引号的生产安装(工作)

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 删除 php-mysql

yum 安装 php-mysqlnd

php -m | grep mysqlnd

关于php - Eloquent 模型中 id 周围的引号在生产站点上是必需的,但在本地主机上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34235492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com