Index: src/wp-includes/wp-db.php
===================================================================
--- src/wp-includes/wp-db.php	(revision 26270)
+++ src/wp-includes/wp-db.php	(working copy)
@@ -15,24 +15,28 @@
 define( 'EZSQL_VERSION', 'WP1.25' );
 
 /**
+ * @since ?.? Added random string to prevent collisions in wpdb::auto_prepare()
  * @since 0.71
  */
-define( 'OBJECT', 'OBJECT', true );
+define( 'OBJECT', 'OBJECT.' . md5( microtime() ), true );
 
 /**
+ * @since ?.? Added random string to prevent collisions in wpdb::auto_prepare()
  * @since 2.5.0
  */
-define( 'OBJECT_K', 'OBJECT_K' );
+define( 'OBJECT_K', 'OBJECT_K.' . md5( microtime() ) );
 
 /**
+ * @since ?.? Added random string to prevent collisions in wpdb::auto_prepare()
  * @since 0.71
  */
-define( 'ARRAY_A', 'ARRAY_A' );
+define( 'ARRAY_A', 'ARRAY_A.' . md5( microtime() ) );
 
 /**
+ * @since ?.? Added random string to prevent collisions in wpdb::auto_prepare()
  * @since 0.71
  */
-define( 'ARRAY_N', 'ARRAY_N' );
+define( 'ARRAY_N', 'ARRAY_N.' . md5( microtime() ) );
 
 /**
  * WordPress Database Access Abstraction Object
@@ -1007,6 +1011,61 @@
 	}
 
 	/**
+	 * Takes the query and arguments passed to the calling function, calling wpdb::prepare if needed.
+	 *
+	 * This will update the passed $query and $output variables based on what's found in $args.
+	 * If passed the arguments that don't match one of the output flags, and pass it along to
+	 * wpdb::prepare() to modify the $query arg before it gets used in the calling function.
+	 *
+	 * @since ?.?
+	 *
+	 * @uses OBJECT For output method detection.
+	 * @uses OBJECT_K For output method detection.
+	 * @uses ARRAY_A For output method detection.
+	 * @uses ARRAY_N For output method detection.
+	 * @uses wpdb::prepare() To prepare the query using the found prepare arguments.
+	 *
+	 * @param array  $args    The arguments passed to the calling function.
+	 * @param string $query   The query that was passed to the calling function.
+	 * @param string &$output The output format the calling function should use (by reference).
+	 *
+	 * @return null|false|string The result of wpdb::prepare(), null if no query is passed.
+	 */
+	private function auto_prepare( $args = array(), $query = null, &$output = OBJECT ) {
+		if ( is_null( $query ) ) {
+			return;
+		}
+
+		if ( count( $args ) > 1 ) {
+			// The first argument is the $query, extract it.
+			$query = array_shift( $args );
+
+			// Test if the first or last argument matches one of the output flags.
+			// These flags have been updated to random values, to avoid colisions
+			// with actual prepare arguments.
+			$outputs = array( OBJECT, OBJECT_K, ARRAY_A, ARRAY_N );
+			if ( in_array( $args[0], $outputs, true ) ) {
+				$output = array_shift( $args );
+			} elseif ( in_array( end( $args ), $outputs, true ) ) {
+				$output = array_pop( $args );
+			}
+
+			// Check if theres is only one argument, and that
+			// it's the array of prepare values (it could happen),
+			// make it the $args array if so.
+			if ( count( $args ) == 1 && is_array( $args[0] ) ) {
+				$args = $args[0];
+			}
+
+			// Make sure there are remaining arguments to use.
+			if ( count( $args ) > 0 ) {
+				// Call wpdb::prepare() and pass it's result to $query
+				$query = $this->prepare( $query, $args );
+			}
+		}
+	}
+
+	/**
 	 * Print SQL/DB error.
 	 *
 	 * @since 0.71
@@ -1172,6 +1231,7 @@
 	 *
 	 * More information can be found on the codex page.
 	 *
+	 * @since ?.? Added auto_prepare usage.
 	 * @since 0.71
 	 *
 	 * @param string $query Database query
@@ -1180,6 +1240,12 @@
 	function query( $query ) {
 		if ( ! $this->ready )
 			return false;
+
+		// Try auto_prepare if other arguments were passed.
+		if( func_num_args() > 1 ) {
+			$query = $this->auto_prepare( func_get_args(), $query );
+		}
+
 		/**
 		 * Filter the database query.
 		 *
@@ -1452,6 +1518,31 @@
 	}
 
 	/**
+	 * Retrieve the first selected value from the database.
+	 *
+	 * Auto prepares and calls wpdb::get_var().
+	 *
+	 * @since ?.?
+	 *
+	 * @uses wpdb::auto_prepare() If other arguments are passed to it.
+	 * @uses wpdb::get_var() To execute the auto prepared query.
+	 *
+	 * @param string $query   SQL query.
+	 * @param mixed  $args... The output, and/or the variables to pass through wpdb::auto_prepare().
+	 *
+	 * @return string|null Database query result (as string), or null on failure.
+	 */
+	function get_var_prepared( $query ){
+		$this->func_call = "\$db->get_var_prepared(\"$query\", ".implode(', ', func_get_args()).")";
+
+		if( func_num_args() > 1 ) {
+			$query = $this->auto_prepare( func_get_args(), $query );
+		}
+
+		return $this->get_var( $query );
+	}
+
+	/**
 	 * Retrieve one row from the database.
 	 *
 	 * Executes a SQL query and returns the row from the SQL result.
@@ -1486,6 +1577,31 @@
 	}
 
 	/**
+	 * Retrieve the first selected row from the database.
+	 *
+	 * Auto prepares and calls wpdb::get_row().
+	 *
+	 * @since ?.?
+	 *
+	 * @uses wpdb::auto_prepare() If other arguments are passed to it.
+	 * @uses wpdb::get_row() To execute the auto prepared query.
+	 *
+	 * @param string $query   SQL query.
+	 * @param mixed  $args... The output, and/or the variables to pass through wpdb::auto_prepare().
+	 *
+	 * @return mixed Database query result in format specified by $output or null on failure.
+	 */
+	function get_row_prepared( $query ){
+		$this->func_call = "\$db->get_row_prepared(\"$query\", ".implode(', ', func_get_args()).")";
+
+		if( func_num_args() > 1 ) {
+			$query = $this->auto_prepare( func_get_args(), $query, $output );
+		}
+
+		return $this->get_row( $query, $output );
+	}
+
+	/**
 	 * Retrieve one column from the database.
 	 *
 	 * Executes a SQL query and returns the column from the SQL result.
@@ -1511,6 +1627,31 @@
 	}
 
 	/**
+	 * Retrieve the first selected column from the database.
+	 *
+	 * Auto prepares and calls wpdb::get_col().
+	 *
+	 * @since ?.?
+	 *
+	 * @uses wpdb::auto_prepare() If other arguments are passed to it.
+	 * @uses wpdb::get_col() To execute the auto prepared query.
+	 *
+	 * @param string $query   SQL query.
+	 * @param mixed  $args... The output, and/or the variables to pass through wpdb::auto_prepare().
+	 *
+	 * @return mixed Database query results. Array indexed from 0 by SQL result row number.
+	 */
+	function get_col_prepared( $query ){
+		$this->func_call = "\$db->get_col_prepared(\"$query\", ".implode(', ', func_get_args()).")";
+
+		if( func_num_args() > 1 ) {
+			$query = $this->auto_prepare( func_get_args(), $query );
+		}
+
+		return $this->get_col( $query );
+	}
+
+	/**
 	 * Retrieve an entire SQL result set from the database (i.e., many rows)
 	 *
 	 * Executes a SQL query and returns the entire SQL result.
@@ -1564,6 +1705,32 @@
 	}
 
 	/**
+	 * Retrieve the results from the database.
+	 *
+	 * Auto prepares and calls wpdb::get_results().
+	 *
+	 * @since ?.?
+	 *
+	 * @uses wpdb::auto_prepare() If other arguments are passed to it.
+	 * @uses wpdb::get_results() To execute the auto prepared query.
+	 *
+	 * @param string $query   SQL query.
+	 * @param mixed  $args... The output, and/or the variables to pass through wpdb::auto_prepare().
+	 *
+	 * @return mixed Database query results.
+	 */
+	function get_results_prepared( $query ){
+		$this->func_call = "\$db->get_results_prepared(\"$query\", ".implode(', ', func_get_args()).")";
+
+		if( func_num_args() > 1 ) {
+			$query = $this->auto_prepare( func_get_args(), $query, $output );
+		}
+
+		// Pass to get_results
+		return $this->get_results( $query, $output );
+	}
+
+	/**
 	 * Load the column metadata from the last query.
 	 *
 	 * @since 3.5.0
