Commit 8c8b3058 authored by Dries's avatar Dries

- Added "query log" functionality to Drupal.  Inspired by weitzman's
  code/patch.
parent 2ac4e99f
......@@ -422,7 +422,14 @@ function timer_print() {
global $timer;
$stop = explode(" ", microtime());
$diff = $stop[0] - $timer[0];
print "<PRE>execution time: $diff ms</PRE>";
print "<pre>execution time: $diff ms</pre>";
}
function query_print() {
global $queries;
print "<pre>";
print_r($queries);
print "</pre>";
}
function page_header() {
......@@ -443,6 +450,10 @@ function page_footer() {
timer_print();
}
if (variable_get("dev_query", 0)) {
query_print();
}
if (variable_get("cache", 0)) {
cache_set();
}
......
......@@ -10,6 +10,11 @@ function db_connect($url) {
}
function db_query($query, $debug = 0) {
global $queries;
if (variable_get("dev_query", 0)) {
$queries[] = $query;
}
$result = mysql_query($query);
......
......@@ -16,7 +16,11 @@ function db_connect($url) {
}
function db_query($query, $debug = 0) {
global $db_handle;
global $db_handle, $queries;
if (variable_get("dev_query", 0)) {
$queries[] = $query;
}
$result = $db_handle->query($query);
......
......@@ -72,6 +72,8 @@ function system_view_options() {
// development settings:
$output .= "<h3>Development settings</h3>\n";
$output .= form_select("Display timer information", "dev_timer", variable_get("dev_timer", 0), array("Disabled", "Enabled"), "Display the time it took to generate a page. For Drupal development only.");
$output .= form_select("Display query log", "dev_query", variable_get("dev_query", 0), array("Disabled", "Enabled"), "Display a log of the database queries needed to generate the current page.");
$output .= "<hr />\n";
foreach (module_list() as $name) {
......
......@@ -72,6 +72,8 @@ function system_view_options() {
// development settings:
$output .= "<h3>Development settings</h3>\n";
$output .= form_select("Display timer information", "dev_timer", variable_get("dev_timer", 0), array("Disabled", "Enabled"), "Display the time it took to generate a page. For Drupal development only.");
$output .= form_select("Display query log", "dev_query", variable_get("dev_query", 0), array("Disabled", "Enabled"), "Display a log of the database queries needed to generate the current page.");
$output .= "<hr />\n";
foreach (module_list() as $name) {
......
......@@ -65,7 +65,7 @@ function user_load($array = array()) {
$query .= "u.$key = '". addslashes($value) ."' AND ";
}
}
$result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE $query u.status < 3");
$result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE $query u.status < 3 LIMIT 1");
$user = db_fetch_object($result);
......
......@@ -65,7 +65,7 @@ function user_load($array = array()) {
$query .= "u.$key = '". addslashes($value) ."' AND ";
}
}
$result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE $query u.status < 3");
$result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE $query u.status < 3 LIMIT 1");
$user = db_fetch_object($result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment