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

Quotation marks around id in eloquent models are necessary on production site but don't work on localhost

所以我有一个疑问,在我的生产安装中需要在 'where' 方法中围绕 "id" 引号,否则 returns 没有结果。在我的本地安装中,情况正好相反。如果我使用引号,它就不起作用。

生产

'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