[wp-cvs] wordpress/wp-includes wp-db.php,1.13,1.14

Matthew Mullenweg saxmatt at users.sourceforge.net
Fri Aug 20 17:52:52 UTC 2004


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20262/wp-includes

Modified Files:
	wp-db.php 
Log Message:
Some profiling info in $wpdb optionally.

Index: wp-db.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/wp-db.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** wp-db.php	23 Jul 2004 01:35:56 -0000	1.13
--- wp-db.php	20 Aug 2004 17:52:49 -0000	1.14
***************
*** 10,13 ****
--- 10,14 ----
  define('ARRAY_A', 'ARRAY_A', false);
  define('ARRAY_N', 'ARRAY_N', false);
+ 
  if (!defined('SAVEQUERIES'))
  	define('SAVEQUERIES', false);
***************
*** 19,22 ****
--- 20,24 ----
  	var $last_query;
  	var $col_info;
+ 	var $queries;
  
  	// Our tables
***************
*** 39,43 ****
  
  	function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
! 		$this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);
  		if (!$this->dbh) {
  			$this->bail("
--- 41,45 ----
  
  	function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
! 		$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
  		if (!$this->dbh) {
  			$this->bail("
***************
*** 60,64 ****
  
  	function select($db) {
! 		if (!@mysql_select_db($db,$this->dbh)) {
  			$this->bail("
  <h1>Can&#8217;t select database</h1>
--- 62,66 ----
  
  	function select($db) {
! 		if (!@mysql_select_db($db, $this->dbh)) {
  			$this->bail("
  <h1>Can&#8217;t select database</h1>
***************
*** 135,143 ****
  
  		// Perform the query via std mysql_query function..
! 		$this->result = @mysql_query($query,$this->dbh);
  		++$this->num_queries;
! 		if (SAVEQUERIES) {
! 			$this->savedqueries[] = $query;
! 		}
  
  		// If there is an error then take note of it..
--- 137,148 ----
  
  		// Perform the query via std mysql_query function..
! 		if (SAVEQUERIES)
! 			$this->timer_start();
! 		
! 		$this->result = @mysql_query($query, $this->dbh);
  		++$this->num_queries;
! 
! 		if (SAVEQUERIES)
! 			$this->queries[] = array( $query, $this->timer_stop() );
  
  		// If there is an error then take note of it..
***************
*** 279,337 ****
  	}
  
! 	function bail($message) { // Just wraps errors in a nice header and footer
! echo <<<HEAD
! <!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">
! <head>
! 	<title>WordPress &rsaquo; Installation</title>
! 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
! 	<style media="screen" type="text/css">
! 	<!--
! 	html {
! 		background: #eee;
! 	}
! 	body {
! 		background: #fff;
! 		color: #000;
! 		font-family: Georgia, "Times New Roman", Times, serif;
! 		margin-left: 25%;
! 		margin-right: 25%;
! 		padding: .2em 2em;
! 	}
! 	
! 	h1 {
! 		color: #006;
! 		font-size: 18px;
! 		font-weight: lighter;
! 	}
! 	
! 	h2 {
! 		font-size: 16px;
  	}
  	
! 	p, li, dt {
! 		line-height: 140%;
! 		padding-bottom: 2px;
  	}
  
! 	ul, ol {
! 		padding: 5px 5px 5px 20px;
! 	}
! 	#logo {
! 		margin-bottom: 2em;
! 	}
! 	-->
! 	</style>
! </head>
! <body>
! <h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
  HEAD;
! echo $message;
! echo "</body></html>";
! die();
  	}
  }
  
  $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
- 
  ?>
\ No newline at end of file
--- 284,358 ----
  	}
  
! 	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
! 	if ( !$this->show_errors )
! 		return false;
! 	echo <<<HEAD
! 	<!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">
! 	<head>
! 		<title>WordPress &rsaquo; Error</title>
! 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
! 		<style media="screen" type="text/css">
! 		<!--
! 		html {
! 			background: #eee;
! 		}
! 		body {
! 			background: #fff;
! 			color: #000;
! 			font-family: Georgia, "Times New Roman", Times, serif;
! 			margin-left: 25%;
! 			margin-right: 25%;
! 			padding: .2em 2em;
! 		}
! 		
! 		h1 {
! 			color: #006;
! 			font-size: 18px;
! 			font-weight: lighter;
! 		}
! 		
! 		h2 {
! 			font-size: 16px;
! 		}
! 		
! 		p, li, dt {
! 			line-height: 140%;
! 			padding-bottom: 2px;
! 		}
! 	
! 		ul, ol {
! 			padding: 5px 5px 5px 20px;
! 		}
! 		#logo {
! 			margin-bottom: 2em;
! 		}
! 		-->
! 		</style>
! 	</head>
! 	<body>
! 	<h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
  HEAD;
! 	echo $message;
! 	echo "</body></html>";
! 	die();
  	}
  }
  
  $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
  ?>
\ No newline at end of file




More information about the cvs mailing list