+
+ /**
+ * Update a row in the table
+ *
+ * <code>
+ * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) )
+ * </code>
+ *
+ * @since 2.5.0
+ * @see wpdb::prepare()
+ *
+ * @param string $table table name
+ * @param array $data Data to update (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
+ * @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 $format (optional) An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings.
+ * @param array|string $format_where (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', '%s' (decimal number, string). If omitted, all values in $where will be treated as strings.
+ * @return int|false The number of rows updated, or false on error.
+ */
+ function update($table, $data, $where, $format = null, $where_format = null) {
+ if ( !is_array( $where ) )
+ return false;
+
+ $formats = $format = (array) $format;
+ $bits = $wheres = 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';
+ $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}";
+ }
+
+ $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
+ return $this->query( $this->prepare( $sql, array_merge(array_values($data), array_values($where))) );
+ }
+
+ /**
+ * Retrieve one variable from the database.
+ *
+ * Executes a SQL query and returns the value from the SQL result.
+ * If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified.
+ * If $query is null, this function returns the value in the specified column and row from the previous SQL result.
+ *
+ * @since 0.71
+ *
+ * @param string|null $query SQL query. If null, use the result from the previous query.
+ * @param int $x (optional) Column of value to return. Indexed from 0.
+ * @param int $y (optional) Row of value to return. Indexed from 0.
+ * @return string Database query result
+ */