Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 3557)
+++ wp-includes/wp-db.php	(working copy)
@@ -36,9 +36,13 @@
 	var $optiongroup_options;
 	var $postmeta;
 
-	// ==================================================================
-	//	DB Constructor - connects to the server and selects a database
-
+	/**
+	 * Connects to the database server and selects a database
+	 * @param string $dbuser
+	 * @param string $dbpassword
+	 * @param string $dbname
+	 * @param string $dbhost
+	 */
 	function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
 		$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
 		if (!$this->dbh) {
@@ -57,9 +61,10 @@
 		$this->select($dbname);
 	}
 
-	// ==================================================================
-	//	Select a DB (if another one needs to be selected)
-
+	/**
+	 * Selects a database using the current class's $this->dbh
+	 * @param string $db name
+	 */
 	function select($db) {
 		if (!@mysql_select_db($db, $this->dbh)) {
 			$this->bail("
@@ -73,9 +78,12 @@
 		}
 	}
 
-	// ====================================================================
-	//	Format a string correctly for safe insert under all PHP conditions
-
+	/**
+	 * Escapes content for insertion into the database, for security
+	 *
+	 * @param string $string
+	 * @return string query safe string
+	 */
 	function escape($string) {
 		return addslashes( $string ); // Disable rest for now, causing problems
 		if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' )
@@ -105,29 +113,34 @@
 		}
 	}
 
-	// ==================================================================
-	//	Turn error handling on or off..
-
+	/**
+	 * Turn error reporting for SQL errors on
+	 */
 	function show_errors() {
 		$this->show_errors = true;
 	}
 
+	/**
+	 * Turn error reporting for SQL errors off
+	 */
 	function hide_errors() {
 		$this->show_errors = false;
 	}
 
-	// ==================================================================
-	//	Kill cached query results
-
+	/**
+	 * Flush the internal wpdb cache which stores the last query's results
+	 */
 	function flush() {
 		$this->last_result = null;
 		$this->col_info = null;
 		$this->last_query = null;
 	}
 
-	// ==================================================================
-	//	Basic Query	- see docs for more detail
-
+	/**
+	 * Simply run an SQL query
+	 * @param string $query
+	 * @return mixed number of rows affected/selected
+	 */
 	function query($query) {
 		// initialise return
 		$return_val = 0;
@@ -145,7 +158,7 @@
 
 		$this->result = @mysql_query($query, $this->dbh);
 		++$this->num_queries;
-
+	
 		if (SAVEQUERIES)
 			$this->queries[] = array( $query, $this->timer_stop() );
 
@@ -187,9 +200,13 @@
 		return $return_val;
 	}
 
-	// ==================================================================
-	//	Get one variable from the DB - see docs for more detail
-
+	/**
+	 * Get one variable from the database
+	 * @param string $query (can be null as well, for caching, see codex)
+	 * @param int $x = 0 row num to return
+	 * @param int $y = 0 col num to return
+	 * @return mixed results
+	 */
 	function get_var($query=null, $x = 0, $y = 0) {
 		$this->func_call = "\$db->get_var(\"$query\",$x,$y)";
 		if ( $query )
@@ -204,9 +221,13 @@
 		return (isset($values[$x]) && $values[$x]!=='') ? $values[$x] : null;
 	}
 
-	// ==================================================================
-	//	Get one row from the DB - see docs for more detail
-
+	/**
+	 * Get one row from the database
+	 * @param string $query
+	 * @param string $output ARRAY_A | ARRAY_N | OBJECT
+	 * @param int $y row num to return
+	 * @return mixed results
+	 */
 	function get_row($query = null, $output = OBJECT, $y = 0) {
 		$this->func_call = "\$db->get_row(\"$query\",$output,$y)";
 		if ( $query )
@@ -223,10 +244,12 @@
 		}
 	}
 
-	// ==================================================================
-	//	Function to get 1 column from the cached result set based in X index
-	// se docs for usage and info
-
+	/**
+	 * Gets one column from the database
+	 * @param string $query (can be null as well, for caching, see codex)
+	 * @param int $x col num to return
+	 * @return array results
+	 */
 	function get_col($query = null , $x = 0) {
 		if ( $query )
 			$this->query($query);
@@ -238,9 +261,12 @@
 		return $new_array;
 	}
 
-	// ==================================================================
-	// Return the the query as a result set - see docs for more details
-
+	/**
+	 * Return an entire result set from the database
+	 * @param string $query (can also be null to pull from the cache)
+	 * @param string $output ARRAY_A | ARRAY_N | OBJECT
+	 * @return mixed results
+	 */
 	function get_results($query = null, $output = OBJECT) {
 		$this->func_call = "\$db->get_results(\"$query\", $output)";
 
@@ -267,11 +293,12 @@
 		}
 	}
 
-
-	// ==================================================================
-	// Function to get column meta data info pertaining to the last query
-	// see docs for more info and usage
-
+	/**
+	 * Grabs column metadata from the last query
+	 * @param string $info_type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill
+	 * @param int $col_offset 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type
+	 * @return mixed results
+	 */
 	function get_col_info($info_type = 'name', $col_offset = -1) {
 		if ( $this->col_info ) {
 			if ( $col_offset == -1 ) {
@@ -287,6 +314,9 @@
 		}
 	}
 
+	/**
+	 * Starts the timer, for debugging purposes
+	 */
 	function timer_start() {
 		$mtime = microtime();
 		$mtime = explode(' ', $mtime);
@@ -294,7 +324,11 @@
 		return true;
 	}
 
-	function timer_stop($precision = 3) {
+	/**
+	 * Stops the debugging timer
+	 * @return int total time spent on the query, in milliseconds
+	 */
+	function timer_stop() {
 		$mtime = microtime();
 		$mtime = explode(' ', $mtime);
 		$time_end = $mtime[1] + $mtime[0];
@@ -302,6 +336,10 @@
 		return $time_total;
 	}
 
+	/**
+	 * Wraps fatal errors in a nice header and footer and dies.
+	 * @param string $message
+	 */
 	function bail($message) { // Just wraps errors in a nice header and footer
 	if ( !$this->show_errors )
 		return false;

