From 3f2f66629fda0b34dc9e5000080ec2f60e6e5ee9 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Sun, 1 May 2016 12:42:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E7=B4=80=E9=8C=84=E9=80=80=E5=87=BA?= =?UTF-8?q?=E5=AD=B8=E7=BF=92=E9=BB=9E=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/Database/DBStudy.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/lib/Database/DBStudy.php b/htdocs/lib/Database/DBStudy.php index 032f120..bf34120 100644 --- a/htdocs/lib/Database/DBStudy.php +++ b/htdocs/lib/Database/DBStudy.php @@ -41,7 +41,7 @@ class DBStudy extends Database { protected function queryByWhere($where) { $sqlString = "SELECT `SID`, `SaID`, ". - "`TID`, `IsEnter`, `IsEntity`, `In_TargetTime`, `Out_TargetTime` ". + "`TID`, IF(ISNULL(`Out_TargetTime`),1,0) AS `IsEnter`, `IsEntity`, `In_TargetTime`, `Out_TargetTime` ". "FROM `".$this->table('user_history')."` ". "WHERE ".$where; @@ -253,9 +253,7 @@ class DBStudy extends Database { } // 寫入 - $sqlString = "INSERT INTO `".$this->table('user_history'). - "` (`SaID`, `TID`, `IsEnter`, `IsEntity`, `In_TargetTime`, `Out_TargetTime`) - VALUES ( :said , :tid , '1' , :entity , NOW() , NULL )"; + $sqlString = "INSERT INTO `".$this->table('user_history')."` (`SID`, `SaID`, `TID`, `IsEntity`, `In_TargetTime`, `Out_TargetTime`) VALUES (NULL, :said , :tid , :entity , NOW(), NULL)"; $query = $this->connDB->prepare($sqlString); $query->bindParam(":said", $activity_id); @@ -488,8 +486,7 @@ class DBStudy extends Database { $queryResultAll = $this->queryByWhere( "`TID` = ".$this->connDB->quote($target_id). " AND `SaID` = ".$this->connDB->quote($activity_id). - " AND `Out_TargetTime` IS NULL ". - " AND `IsEnter` = '1'"); + " AND `Out_TargetTime` IS NULL "); return $queryResultAll; }