mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-01 05:01:35 +01:00
Some profiling info in $wpdb optionally.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1543 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3c6bc4ae08
commit
38545517b1
@ -9,6 +9,7 @@ define('EZSQL_VERSION', 'WP1.25');
|
|||||||
define('OBJECT', 'OBJECT', true);
|
define('OBJECT', 'OBJECT', true);
|
||||||
define('ARRAY_A', 'ARRAY_A', false);
|
define('ARRAY_A', 'ARRAY_A', false);
|
||||||
define('ARRAY_N', 'ARRAY_N', false);
|
define('ARRAY_N', 'ARRAY_N', false);
|
||||||
|
|
||||||
if (!defined('SAVEQUERIES'))
|
if (!defined('SAVEQUERIES'))
|
||||||
define('SAVEQUERIES', false);
|
define('SAVEQUERIES', false);
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ class wpdb {
|
|||||||
var $num_queries = 0;
|
var $num_queries = 0;
|
||||||
var $last_query;
|
var $last_query;
|
||||||
var $col_info;
|
var $col_info;
|
||||||
|
var $queries;
|
||||||
|
|
||||||
// Our tables
|
// Our tables
|
||||||
var $posts;
|
var $posts;
|
||||||
@ -134,11 +136,14 @@ class wpdb {
|
|||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
|
|
||||||
// Perform the query via std mysql_query function..
|
// Perform the query via std mysql_query function..
|
||||||
|
if (SAVEQUERIES)
|
||||||
|
$this->timer_start();
|
||||||
|
|
||||||
$this->result = @mysql_query($query, $this->dbh);
|
$this->result = @mysql_query($query, $this->dbh);
|
||||||
++$this->num_queries;
|
++$this->num_queries;
|
||||||
if (SAVEQUERIES) {
|
|
||||||
$this->savedqueries[] = $query;
|
if (SAVEQUERIES)
|
||||||
}
|
$this->queries[] = array( $query, $this->timer_stop() );
|
||||||
|
|
||||||
// If there is an error then take note of it..
|
// If there is an error then take note of it..
|
||||||
if ( mysql_error() ) {
|
if ( mysql_error() ) {
|
||||||
@ -278,12 +283,29 @@ class wpdb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function timer_start() {
|
||||||
|
$mtime = microtime();
|
||||||
|
$mtime = explode(' ', $mtime);
|
||||||
|
$this->time_start = $mtime[1] + $mtime[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function timer_stop($precision = 3) {
|
||||||
|
$mtime = microtime();
|
||||||
|
$mtime = explode(' ', $mtime);
|
||||||
|
$time_end = $mtime[1] + $mtime[0];
|
||||||
|
$time_total = $time_end - $this->time_start;
|
||||||
|
return $timetotal;
|
||||||
|
}
|
||||||
|
|
||||||
function bail($message) { // Just wraps errors in a nice header and footer
|
function bail($message) { // Just wraps errors in a nice header and footer
|
||||||
|
if ( !$this->show_errors )
|
||||||
|
return false;
|
||||||
echo <<<HEAD
|
echo <<<HEAD
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>WordPress › Installation</title>
|
<title>WordPress › Error</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<style media="screen" type="text/css">
|
<style media="screen" type="text/css">
|
||||||
<!--
|
<!--
|
||||||
@ -333,5 +355,4 @@ die();
|
|||||||
}
|
}
|
||||||
|
|
||||||
$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user