$uid = $_GET['uid'];
if ($uid) { // 很机智
vendor("Func.Func");
if (Func::checkMobile($uid)) {
$uid = $user->where(['telphone' => $uid])->getField('id');
}
$where['uid'] = $uid;
$this->assign('uid', $_GET['uid']);
$tail .= '&uid=' . $_GET['uid'];
}
$act_name = trim($_GET['act_name']);
$groupModel = M('group_purchase');
if ($act_name) {
$this->assign('act_name', $act_name);
$tail .= '&act_name=' . $act_name;
$group_flag = $groupModel->where(['title' => ['like', '%' . $act_name . '%']])->field('id')->select();
$group_ids = [];
foreach ($group_flag as $v) {
$group_ids[] = $v['id'];
}
$where['group_id'] = ['in', $group_ids];
}
$group_id = trim($_GET['group_id']);
if ($group_id) {
$this->assign('group_id', $group_id);
$tail .= '&group_id=' . $group_id;
$where['group_id'] = $group_id;
}
这段查询,很机智。
灵活判断,分别处理。
直接查不到,那就间接查询。