Parcourir la source

自动查数据库加异常处理

visuddhinanda il y a 5 ans
Parent
commit
a4c181028d
1 fichiers modifiés avec 12 ajouts et 5 suppressions
  1. 12 5
      app/studio/dict_find_one.php

+ 12 - 5
app/studio/dict_find_one.php

@@ -131,11 +131,18 @@ 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);
-			if($stmt ){
-				$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
-			}
-			else{
+			try {
+				$stmt = $db_file["dbh"]->query($query);
+				if($stmt ){
+					$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+				}
+				else{
+					$Fetch = array();
+				}
+			}catch (PDOException $e) {
+				if($debug){
+					print "Error!: " . $e->getMessage() . "<br/>";
+				}
 				$Fetch = array();
 				$Fetch = array();
 			}
 			}
 		}
 		}