php – 在eloquent模型中围绕id的引号在生产站点上是必需的,但不适用于localhost

前端之家收集整理的这篇文章主要介绍了php – 在eloquent模型中围绕id的引号在生产站点上是必需的,但不适用于localhost前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我有一个查询,在我的生产安装中需要在’where’方法中的“id”周围引用,否则不返回任何结果.在我的本地安装上,正好相反.如果我使用报价,它就不起作用了.

生产

‘发票’=> Auth :: user() – > invoices-> where(‘paid’,“0”)

本地主机

‘发票’=> Auth :: user() – > invoices-> where(‘paid’,0)

这真的很奇怪,每当我从github部署时,我都非常想进入并改变它.这是一个常见的问题吗?我似乎找不到任何关于它的东西.

我将列出一些Laravel查询日志:

在int周围进行本地安装(不工作)

  1. Array (
  2. [0] => Array (
  3. [query] => select * from `users` where `users`.`id` = ? limit 1
  4. [bindings] => Array (
  5. [0] => 1
  6. )
  7. [time] => 10.49
  8. )
  9. [1] => Array (
  10. [query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
  11. [bindings] => Array (
  12. [0] => 1
  13. )
  14. [time] => 1.39
  15. )
  16. )

在int(工作)周围没有引用的本地安装

  1. Array (
  2. [0] => Array (
  3. [query] => select * from `users` where `users`.`id` = ? limit 1
  4. [bindings] => Array (
  5. [0] => 1
  6. )
  7. [time] => 0.84
  8. )
  9. [1] => Array (
  10. [query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
  11. [bindings] => Array (
  12. [0] => 1
  13. )
  14. [time] => 1.15
  15. )
  16. )

生产安装没有引用int(不工作)

  1. Array (
  2. [0] => Array (
  3. [query] => select * from `users` where `users`.`id` = ? limit 1
  4. [bindings] => Array (
  5. [0] => 1
  6. )
  7. [time] => 2.3
  8. )
  9. [1] => Array (
  10. [query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
  11. [bindings] => Array (
  12. [0] => 1
  13. )
  14. [time] => 0.67
  15. )
  16. )

围绕int(工作)报价的生产安装

  1. Array (
  2. [0] => Array (
  3. [query] => select * from `users` where `users`.`id` = ? limit 1
  4. [bindings] => Array (
  5. [0] => 1
  6. )
  7. [time] => 0.88
  8. )
  9. [1] => Array (
  10. [query] => select * from `invoices` where `invoices`.`user_id` = ? and `invoices`.`user_id` is not null
  11. [bindings] => Array (
  12. [0] => 1
  13. )
  14. [time] => 0.81
  15. )
  16. )

解:

事实证明我没有MysqLnd作为我服务器上的活动驱动程序.激活它解决了这个问题.

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

yum删除PHP-MysqL

yum安装PHP-MysqLnd

PHP -m | grep MysqLnd

猜你在找的PHP相关文章