ekequent模型中id周围的引号在生产现场是必要的,但不能在localhost上工作

时间:2015-12-12 02:18:10

标签: php mysql laravel laravel-5

所以我有一个查询,在我的生产安装上需要引用" 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作为我服务器上的活动驱动程序。激活它解决了这个问题。

1 个答案:

答案 0 :(得分:0)

事实证明我没有mysqlnd作为我服务器上的活动驱动程序。激活它解决了这个问题。我使用以下命令执行此操作:

yum install php-mysqlnd

php -m | grep mysqlnd

{{1}}