为什么Laravel集合where()和whereIn()在本地和在线环境中的工作方式不同

时间:2017-05-23 02:15:52

标签: php laravel collections

谢谢,我已经知道发生了什么。因为Laravel的版本在本地和在线之间是不同的。 Laravel 5.3和5.2集合中的参数,其中()是不同的。

____这就是Windows / Mac上修补程序的显示[Laravel 5.3] ___

>>> $a = collect([['a'=>1,'b'=>2],['a'=>'1','b'=>3]])
=> Illuminate\Support\Collection {#852
     all: [
       [
         "a" => 1,
         "b" => 2,
       ],
       [
         "a" => "1",
         "b" => 3,
       ],
     ],
   }

>>> $a->where('a',1)
=> Illuminate\Support\Collection {#877
     all: [
       [
         "a" => 1,
         "b" => 2,
       ],
       [
         "a" => "1",
         "b" => 3,
       ],
     ],
   }

>>> $a->whereIn('a',[1])
=> Illuminate\Support\Collection {#877
     all: [
       [
         "a" => 1,
         "b" => 2,
       ],
       [
         "a" => "1",
         "b" => 3,
       ],
     ],
   }

_这就是CentOS服务器上显示的内容 [Laravel 5.2]

>>> $a = collect([['a'=>1,'b'=>2],['a'=>'1','b'=>3]])
=> Illuminate\Support\Collection {#1414
     all: [
       [
         "a" => 1,
         "b" => 2,
       ],
       [
         "a" => "1",
         "b" => 3,
       ],
     ],
   }

>>> $a->where('a',1)
=> Illuminate\Support\Collection {#1394
     all: [
       [
         "a" => 1,
         "b" => 2,
       ],
     ],
   }

>>> $a->whereIn('a',[1])
=> Illuminate\Support\Collection {#1388
     all: [
       [
         "a" => 1,
         "b" => 2,
       ],
     ],
   }

我读过Laravel集合文档,它说,whereIn和whereInLoose一样(但是自5.3以来whereInLoose被删除了),但在我的服务器上,whereIn工作就像whereInStrict一样,当我不确定什么是数字集合值类型时是的,它总是在集合中找不到任何东西,然后导致致命的错误。有人知道它发生了什么以及为什么会发生,谢谢!

0 个答案:

没有答案