aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/database.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-03 11:27:43 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-03 11:27:43 +0000
commit0f2e279f16fc70542fc86a0896ab635b519831be (patch)
treef08d1fc5af4f2c990659d48ce972d50fb8cc6cdc /engine/lib/database.php
parent1e727b299b533535ba2351a6a96d6e05f3c3a34c (diff)
downloadelgg-0f2e279f16fc70542fc86a0896ab635b519831be.tar.gz
elgg-0f2e279f16fc70542fc86a0896ab635b519831be.tar.bz2
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
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r--engine/lib/database.php41
1 files changed, 27 insertions, 14 deletions
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;
}
/**