我有一个 json 列,默认设置为 null 并在模型中转换为数组。 我用过
->where('column_name', '\[\]')->get();
它返回空集合。
我的问题是,如果我必须检查列是否为空数组,在什么情况下我该怎么办?
感谢这个答案
where('column_name',DB::raw("json_array()"))->get();
$records = Activity::query();
$records->where('properties->old','!=', '[]');
$records->skip($start)->take($rowperpage)->get();
这样可以查询 JSON 列
whereJsonLength('column_name', '>', 0);
这也是检查是否有任何价值的一种方法。