From 42cdb3e7266c58ebd26232a397f9d2aaa14cc7aa Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Tue, 3 Feb 2015 19:02:23 +0800 Subject: [PATCH] =?UTF-8?q?ReviewService=20=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AE=A1=E7=90=86=E5=91=98=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Westdc/Review/Review.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Westdc/Review/Review.php b/Westdc/Review/Review.php index 3675250..8b2b21a 100644 --- a/Westdc/Review/Review.php +++ b/Westdc/Review/Review.php @@ -37,6 +37,8 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac private function init(){ $dbService = $this->serviceManager->get('Db'); + + /** @var \PDO $this->db */ $this->db = $dbService->getPdo(); unset($dbService); @@ -254,13 +256,49 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac return true; } + /** + * 更改管理员 + * @param $id array|int 可以输入数组 + * @param $user_id int : 不能输入数组 + * @return bool|string + */ + public function changeAdmin($id,$user_id) + { + if((!is_numeric($id) && !is_array($id)) || !is_numeric($user_id)) + return false; + + if(is_numeric($id)){ + return $this->db->exec("UPDATE mdstatus SET userid=$user_id WHERE id=$id"); + } + + if(is_array($id)) + { + try{ + $this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->db->beginTransaction(); + foreach($id as $item_id){ + $item_id = $item_id+0; + $this->db->exec("UPDATE mdstatus SET userid=$user_id WHERE id=$item_id"); + } + $this->db->commit(); + return true; + + }catch (\Exception $e){ + $this->db->rollBack(); + return $e->getMessage(); + } + + } + return false; + }//changeAdmin(); + /** * 更改mdstatus中的status字段 * @param $id * @param $status * @return bool */ - function changeStatus($id,$status){ + protected function changeStatus($id,$status){ $statusValues = array( self::REVIEW_STATUS_CANCELED, //取消评审 self::REVIEW_STATUS_DEFAULT, //初始状态