Browse Source

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

AlexHaxe 8 years ago
parent
commit
fcda8adb5f
1 changed files with 4 additions and 4 deletions
  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;
 	}
 
 }