瀏覽代碼

add native mysqli error message when throwing an exception (#6390)

AlexHaxe 8 年之前
父節點
當前提交
fcda8adb5f
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      std/php7/_std/sys/db/Mysql.hx

+ 4 - 4
std/php7/_std/sys/db/Mysql.hx

@@ -63,7 +63,7 @@ private class MysqlConnection implements Connection {
 
 	public function request( s : String ) : ResultSet {
 		var result = db.query(s);
-		if (result == false) throw 'Failed to perform db query';
+		if (result == false) throw 'Failed to perform db query: ' + db.error;
 		if (result == true) return null;
 
 		return new MysqlResultSet(result);
@@ -103,17 +103,17 @@ private class MysqlConnection implements Connection {
 
 	public function startTransaction() : Void {
 		var success = db.begin_transaction();
-		if (!success) throw 'Failed to start transaction';
+		if (!success) throw 'Failed to start transaction: ' + db.error;
 	}
 
 	public function commit() : Void {
 		var success = db.commit();
-		if (!success) throw 'Failed to commit transaction';
+		if (!success) throw 'Failed to commit transaction: ' + db.error;
 	}
 
 	public function rollback() : Void {
 		var success = db.rollback();
-		if (!success) throw 'Failed to rollback transaction';
+		if (!success) throw 'Failed to rollback transaction: ' + db.error;
 	}
 
 }