dongliao2011 2017-05-23 02:15
浏览 64

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

Thanks, I'd already figure out what happened. Because The version of Laravel is different between local and online. the parameter in Laravel 5.3 and 5.2 collection where() are different.

____ This is what show in tinker on 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,
       ],
     ],
   }

_ And This is what show on CentOS server[ 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,
       ],
     ],
   }

I had read Laravel collection doc, and it said, whereIn is same as whereInLoose(however whereInLoose was removed since 5.3), but on my server, whereIn work just like whereInStrict, when I not sure about what a numeric collection value type is, it always find nothing in a collection, then result in a fatal error. Does someone know what and why it happens , Thanks !

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 易康econgnition精度验证
    • ¥15 线程问题判断多次进入
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致