Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 60f95aad6ca27b6fde2c870ce597152b544518fa 2 parents c0038fb + 74fa94b
Aparup Banerjee nebgor authored
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/dml/moodle_database.php
21 lib/dml/moodle_database.php
View
@@ -408,6 +408,7 @@ protected function query_end($result) {
// free memory
$this->last_sql = null;
$this->last_params = null;
+ $this->print_debug_time();
return;
}
@@ -415,7 +416,6 @@ protected function query_end($result) {
$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)
Please sign in to comment.
Something went wrong with that request. Please try again.