Permalink
Browse files

Merge branch 'MDL-37585' of git://github.com/timhunt/moodle

  • Loading branch information...
2 parents c0038fb + 74fa94b commit 60f95aad6ca27b6fde2c870ce597152b544518fa @nebgor nebgor committed Jan 22, 2013
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/dml/moodle_database.php
@@ -408,14 +408,14 @@ protected function query_end($result) {
// free memory
$this->last_sql = null;
$this->last_params = null;
+ $this->print_debug_time();
return;
}
// remember current info, log queries may alter it
$type = $this->last_type;
$sql = $this->last_sql;
$params = $this->last_params;
- $time = microtime(true) - $this->last_time;
$error = $this->get_last_error();
$this->query_log($error);
@@ -521,6 +521,25 @@ protected function print_debug($sql, array $params=null, $obj=null) {
}
/**
+ * Prints the time a query took to run.
+ * @return void
+ */
+ protected function print_debug_time() {
+ if (!$this->get_debug()) {
+ return;
+ }
+ $time = microtime(true) - $this->last_time;
+ $message = "Query took: {$time} seconds.\n";
+ if (CLI_SCRIPT) {
+ echo $message;
+ echo "--------------------------------\n";
+ } else {
+ echo s($message);
+ echo "<hr />\n";
+ }
+ }
+
+ /**
* Returns the SQL WHERE conditions.
* @param string $table The table name that these conditions will be validated against.
* @param array $conditions The conditions to build the where clause. (must not contain numeric indexes)

0 comments on commit 60f95aa

Please sign in to comment.