aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/database.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 158738185..626def70b 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -104,6 +104,18 @@
return $dblink['readwrite'];
}
+ }
+
+ /**
+ * Explain a given query, useful for debug.
+ */
+ function explain_query($query, $link)
+ {
+ if ($result = mysql_query("explain " . $query, $link)) {
+ return mysql_fetch_object($result);
+ }
+
+ return false;
}
/**
@@ -115,12 +127,18 @@
function get_data($query, $callback = "") {
- global $dbcalls;
+ global $CONFIG, $dbcalls;
$dblink = get_db_link('read');
$resultarray = array();
- $dbcalls++;
+ $dbcalls++;
+
+ if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
+ {
+ error_log("--- DB QUERY --- $query");
+ error_log("--- EXPLAINATION --- " . print_r(explain_query($query,$dblink), true));
+ }
if ($result = mysql_query($query, $dblink)) {
while ($row = mysql_fetch_object($result)) {
@@ -149,11 +167,17 @@
function get_data_row($query) {
- global $dbcalls;
+ global $CONFIG, $dbcalls;
$dblink = get_db_link('read');
- $dbcalls++;
+ $dbcalls++;
+
+ if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
+ {
+ error_log("--- DB QUERY --- $query");
+ error_log("--- EXPLAINATION --- " . print_r(explain_query($query,$dblink), true));
+ }
if ($result = mysql_query($query, $dblink)) {
while ($row = mysql_fetch_object($result)) {