Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 21261)
+++ wp-includes/wp-db.php	(working copy)
@@ -1186,6 +1186,29 @@
 	}
 
 	/**
+	 * Helper function for resolving form field formats
+	 *
+	 *
+	 * @access private
+	 * @since 3.5
+	 * @see wpdb::$field_types
+	 *
+	 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data.
+	 * 	A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
+	 * @return string format of value.
+	 */
+	function _field_format( $field, $format = null ) {
+		$formats = (array) $format;
+		if ( ! empty( $format ) )
+			$form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
+		elseif ( isset( $this->field_types[$field] ) )
+			$form = $this->field_types[$field];
+		else
+			$form = '%s';
+		return $form;
+	}
+	
+	/**
 	 * Helper function for insert and replace.
 	 *
 	 * Runs an insert or replace query based on $type argument.
@@ -1206,23 +1229,36 @@
 	function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) {
 		if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ) ) )
 			return false;
-		$formats = $format = (array) $format;
 		$fields = array_keys( $data );
 		$formatted_fields = array();
-		foreach ( $fields as $field ) {
-			if ( !empty( $format ) )
-				$form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
-			elseif ( isset( $this->field_types[$field] ) )
-				$form = $this->field_types[$field];
-			else
-				$form = '%s';
-			$formatted_fields[] = $form;
-		}
+		foreach ( $fields as $field )
+			$formatted_fields[] = $this->_field_format( $field, $format );
+
 		$sql = "{$type} INTO `$table` (`" . implode( '`,`', $fields ) . "`) VALUES (" . implode( ",", $formatted_fields ) . ")";
 		return $this->query( $this->prepare( $sql, $data ) );
 	}
 
 	/**
+	 * Helper function for format of WHERE clauses
+	 *
+	 * @since 3.5.0
+	 * @see wpdb::$field_types
+	 *
+	 * @param array $where A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw".
+	 * @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $where will be treated as strings.
+	 * @return array of formatted field = $value
+	 */
+	function _where_clauses( $where, $where_format = null ) {
+		$wheres = array();
+		foreach ( (array) array_keys( $where ) as $field ) {
+			$form = $this->_field_format( $field, $where_format );
+			$wheres[] = "`$field` = {$form}";
+		}
+		
+		return $wheres;
+	}
+	
+	/**
 	 * Update a row in the table
 	 *
 	 * <code>
@@ -1247,28 +1283,13 @@
 		if ( ! is_array( $data ) || ! is_array( $where ) )
 			return false;
 
-		$formats = $format = (array) $format;
-		$bits = $wheres = array();
+		$bits = array();
 		foreach ( (array) array_keys( $data ) as $field ) {
-			if ( !empty( $format ) )
-				$form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
-			elseif ( isset($this->field_types[$field]) )
-				$form = $this->field_types[$field];
-			else
-				$form = '%s';
+			$form = $this->_field_format( $field, $format );
 			$bits[] = "`$field` = {$form}";
 		}
 
-		$where_formats = $where_format = (array) $where_format;
-		foreach ( (array) array_keys( $where ) as $field ) {
-			if ( !empty( $where_format ) )
-				$form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0];
-			elseif ( isset( $this->field_types[$field] ) )
-				$form = $this->field_types[$field];
-			else
-				$form = '%s';
-			$wheres[] = "`$field` = {$form}";
-		}
+		$wheres = $this->_where_clauses( $where, $where_format );
 
 		$sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
 		return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) );
@@ -1296,22 +1317,8 @@
 		if ( ! is_array( $where ) )
 			return false;
 
-		$bits = $wheres = array();
+		$wheres = $this->_where_clauses( $where, $where_format );
 
-		$where_formats = $where_format = (array) $where_format;
-
-		foreach ( array_keys( $where ) as $field ) {
-			if ( !empty( $where_format ) ) {
-				$form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0];
-			} elseif ( isset( $this->field_types[ $field ] ) ) {
-				$form = $this->field_types[ $field ];
-			} else {
-				$form = '%s';
-			}
-
-			$wheres[] = "$field = $form";
-		}
-
 		$sql = "DELETE FROM $table WHERE " . implode( ' AND ', $wheres );
 		return $this->query( $this->prepare( $sql, $where ) );
 	}
