Browse Source

Merge pull request #249 from visuddhinanda/master

无效查询句柄的判断
visuddhinanda 5 years ago
parent
commit
fa14dfa651
1 changed files with 17 additions and 2 deletions
  1. 17 2
      app/studio/dict_find_one.php

+ 17 - 2
app/studio/dict_find_one.php

@@ -131,8 +131,23 @@ for($i=0;$i<$lookup_loop;$i++)
 			echo $query."<br>";
 			echo $query."<br>";
 		}
 		}
 		if($db_file["dbh"]){
 		if($db_file["dbh"]){
-			$stmt = $db_file["dbh"]->query($query);
-			$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+			try {
+				$stmt = $db_file["dbh"]->query($query);
+				if($stmt ){
+					$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+				}
+				else{
+					$Fetch = array();
+					if($debug){
+						echo "无效的查询句柄";
+					}
+				}
+			}catch (PDOException $e) {
+				if($debug){
+					print "Error!: " . $e->getMessage() . "<br/>";
+				}
+				$Fetch = array();
+			}
 		}
 		}
 		else{
 		else{
 			$Fetch = array();
 			$Fetch = array();