有个关于链式查询的问题
DB::table('goods')
->where(function($query) use($data) {
if (!empty($data['goo_name'] )) {
$query->where('goods.goo_name', 'like' , '%'.$data['goo_name'].'%' );
}
})
->get();
线上php 版本是 5.6 laravel 版本是5.1,后来把线上的PHP升级成PHP 7 ,然后如果链式查询里的where的匿名函数里的判断为假,就报 count(): Parameter must be an array or an object that implements Countable。这个错误。各位大佬,怎么搞。
推荐文章: