我使用whereIn
进行查询我遇到了$idsUsers = empty(json_decode($data["idsUsers"])) ? null : json_decode($data["idsUsers"]);
$articles = DB::table('articles')
->whereIn('user_id',$idsUsers)
->orderBy('created_at','desc')
->paginate(10);
子句的问题,如果数组为空则不会返回结果:
tf.Variable
我如何在whereIn中使用我的数组检查它是否为空或为空
答案 0 :(得分:3)
尝试使用条件:
$articles = DB::table('articles')->orderBy('created_at','desc');
if (!empty($idsUsers)) {
$articles = $articles->whereIn('user_id', $idsUsers);
}
$articles = $articles->paginate(10);
答案 1 :(得分:0)
你可以试试这个
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
// Root view controller loaded while in background, so doing only background stuff
[self justDoBackgroundStuffWithoutUI];
} else {
// Root view controller loaded normally, so loading normal UI
[self initializeUIAndChildControllers];
}
希望这会有所帮助