From 0f2e279f16fc70542fc86a0896ab635b519831be Mon Sep 17 00:00:00 2001 From: icewing Date: Mon, 3 Mar 2008 11:27:43 +0000 Subject: Database errors now distinct from "no data", errors are hard fails git-svn-id: https://code.elgg.org/elgg/trunk@48 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'engine') diff --git a/engine/lib/database.php b/engine/lib/database.php index ba3762a8d..17857bef6 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -128,7 +128,11 @@ } if (empty($resultarray)) { return false; - } + } + + if (mysql_errno($dblink)) + throw new DatabaseException(mysql_error($dblink)); + return $resultarray; } @@ -150,7 +154,11 @@ while ($row = mysql_fetch_object($result)) { return $row; } - } + } + + if (mysql_errno($dblink)) + throw new DatabaseException(mysql_error($dblink)); + return false; } @@ -169,12 +177,13 @@ $dbcalls++; - if (mysql_query($query, $dblink)) { - return mysql_insert_id($dblink); - } else { - return false; - } - + if (mysql_query($query, $dblink)) + return mysql_insert_id($dblink); + + if (mysql_errno($dblink)) + throw new DatabaseException(mysql_error($dblink)); + + return false; } /** @@ -193,7 +202,10 @@ $dbcalls++; if (mysql_query($query, $dblink)) - return mysql_affected_rows(); + return mysql_affected_rows(); + + if (mysql_errno($dblink)) + throw new DatabaseException(mysql_error($dblink)); return false; @@ -214,12 +226,13 @@ $dbcalls++; - if (mysql_query($query, $dblink)) { + if (mysql_query($query, $dblink)) return mysql_affected_rows(); - } else { - return false; - } - + + if (mysql_errno($dblink)) + throw new DatabaseException(mysql_error($dblink)); + + return false; } /** -- cgit v1.2.3