From aa218c913571edbf20c5dfa65e942f8275c03200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 22 Apr 2017 13:44:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/User.php | 9 ++++----- application/wechat/controller/Fans.php | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index c8ba36cc9..0528fbeb2 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -44,11 +44,10 @@ class User extends BasicAdmin { // 实例Query对象 $db = Db::name($this->table)->where('is_deleted', '0'); // 应用搜索条件 - if (isset($get['username']) && $get['username'] !== '') { - $db->where('username', 'like', "%{$get['username']}%"); - } - if (isset($get['phone']) && $get['phone'] !== '') { - $db->where('phone', 'like', "%{$get['phone']}%"); + foreach (['username', 'phone'] as $key) { + if (isset($get[$key]) && $get[$key] !== '') { + $db->where($key, 'like', "%{$get[$key]}%"); + } } // 实例化并显示 parent::_list($db); diff --git a/application/wechat/controller/Fans.php b/application/wechat/controller/Fans.php index 3ad6eff7c..fcab6514b 100644 --- a/application/wechat/controller/Fans.php +++ b/application/wechat/controller/Fans.php @@ -42,8 +42,10 @@ class Fans extends BasicAdmin { $this->title = '微信粉丝管理'; $db = Db::name($this->table); $get = $this->request->get(); - if (isset($get['nickname']) && $get['nickname'] !== '') { - $db->where('nickname', 'like', "%{$get['nickname']}%"); + foreach (['nickname'] as $key) { + if (isset($get[$key]) && $get[$key] !== '') { + $db->where($key, 'like', "%{$get[$key]}%"); + } } return parent::_list($db); }