<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[20287] trunk: Introduce $wpdb->delete().</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/20287">20287</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-03-24 15:24:31 +0000 (Sat, 24 Mar 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Introduce $wpdb->delete(). props justindgivens, scribu. fixes <a href="http://core.trac.wordpress.org/ticket/18948">#18948</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesbookmarkphp">trunk/wp-admin/includes/bookmark.php</a></li>
<li><a href="#trunkwpadminincludesmsphp">trunk/wp-admin/includes/ms.php</a></li>
<li><a href="#trunkwpadminincludesupgradephp">trunk/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunkwpadminincludesuserphp">trunk/wp-admin/includes/user.php</a></li>
<li><a href="#trunkwpincludescommentphp">trunk/wp-includes/comment.php</a></li>
<li><a href="#trunkwpincludesmetaphp">trunk/wp-includes/meta.php</a></li>
<li><a href="#trunkwpincludesmsfunctionsphp">trunk/wp-includes/ms-functions.php</a></li>
<li><a href="#trunkwpincludesoptionphp">trunk/wp-includes/option.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludestaxonomyphp">trunk/wp-includes/taxonomy.php</a></li>
<li><a href="#trunkwpincludeswpdbphp">trunk/wp-includes/wp-db.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesbookmarkphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/bookmark.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/bookmark.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-admin/includes/bookmark.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx">
</span><span class="cx">         wp_delete_object_term_relationships( $link_id, 'link_category' );
</span><span class="cx">
</span><del>-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d", $link_id ) );
</del><ins>+        $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
</ins><span class="cx">
</span><span class="cx">         do_action( 'deleted_link', $link_id );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludesmsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ms.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ms.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-admin/includes/ms.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -89,7 +89,8 @@
</span><span class="cx">                         $wpdb->query( "DROP TABLE IF EXISTS `$table`" );
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) );
</del><ins>+                $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
+
</ins><span class="cx">                 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
</span><span class="cx">                 $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
</span><span class="cx">                 $top_dir = $dir;
</span><span class="lines">@@ -158,8 +159,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) );
-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
</del><ins>+        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
+        $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) );
</ins><span class="cx">
</span><span class="cx">         clean_user_cache( $id );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludesupgradephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/upgrade.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/upgrade.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-admin/includes/upgrade.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -300,7 +300,7 @@
</span><span class="cx">
</span><span class="cx">                 // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
</span><span class="cx">                 if ( !is_super_admin( $user_id ) && $user_id != 1 )
</span><del>-                        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );
</del><ins>+                        $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> endif;
</span></span></pre></div>
<a id="trunkwpadminincludesuserphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/user.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/user.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-admin/includes/user.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -266,11 +266,11 @@
</span><span class="cx">
</span><span class="cx">         // FINALLY, delete user
</span><span class="cx">         if ( !is_multisite() ) {
</span><del>-                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
-                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
</del><ins>+                $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) );
+                $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
</ins><span class="cx">         } else {
</span><span class="cx">                 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
</span><del>-                $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'");
</del><ins>+                $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id , 'meta_key' => $level_key ) );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // allow for commit transaction
</span></span></pre></div>
<a id="trunkwpincludescommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/comment.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -988,7 +988,7 @@
</span><span class="cx">                 do_action( 'deleted_commentmeta', $meta_ids );
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
</del><ins>+        if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) )
</ins><span class="cx">                 return false;
</span><span class="cx">         do_action('deleted_comment', $comment_id);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesmetaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/meta.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/meta.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/meta.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -489,7 +489,7 @@
</span><span class="cx">                         do_action( 'delete_postmeta', $meta_id );
</span><span class="cx">
</span><span class="cx">                 // Run the query, will return true if deleted, false otherwise
</span><del>-                $result = (bool) $wpdb->query( $wpdb->prepare( "DELETE FROM $table WHERE $id_column = %d LIMIT 1;", $meta_id ) );
</del><ins>+                $result = (bool) $wpdb->delete( $table, array( $id_column => $meta_id ) );
</ins><span class="cx">
</span><span class="cx">                 // Clear the caches.
</span><span class="cx">                 wp_cache_delete($object_id, $meta_type . '_meta');
</span></span></pre></div>
<a id="trunkwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-functions.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-functions.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/ms-functions.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -496,7 +496,7 @@
</span><span class="cx">                 $diff = $now - $registered_at;
</span><span class="cx">                 // If registered more than two days ago, cancel registration and let this signup go through.
</span><span class="cx">                 if ( $diff > 172800 )
</span><del>-                        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_login = %s", $user_name) );
</del><ins>+                        $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
</ins><span class="cx">                 else
</span><span class="cx">                         $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
</span><span class="cx">
</span><span class="lines">@@ -509,7 +509,7 @@
</span><span class="cx">                 $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
</span><span class="cx">                 // If registered more than two days ago, cancel registration and let this signup go through.
</span><span class="cx">                 if ( $diff > 172800 )
</span><del>-                        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_email = %s", $user_email) );
</del><ins>+                        $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
</ins><span class="cx">                 else
</span><span class="cx">                         $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
</span><span class="cx">         }
</span><span class="lines">@@ -612,7 +612,7 @@
</span><span class="cx">                 $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
</span><span class="cx">                 // If registered more than two days ago, cancel registration and let this signup go through.
</span><span class="cx">                 if ( $diff > 172800 )
</span><del>-                        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) );
</del><ins>+                        $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
</ins><span class="cx">                 else
</span><span class="cx">                         $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
</span><span class="cx">         }
</span><span class="lines">@@ -1160,9 +1160,10 @@
</span><span class="cx">         $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
</span><span class="cx">
</span><span class="cx">         // remove all perms
</span><del>-        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'user_level') );
-        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'capabilities') );
</del><ins>+        $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) );
</ins><span class="cx">
</span><ins>+        $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) );
+
</ins><span class="cx">         $wpdb->suppress_errors( false );
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesoptionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/option.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/option.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/option.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -367,7 +367,7 @@
</span><span class="cx">         if ( is_null( $row ) )
</span><span class="cx">                 return false;
</span><span class="cx">         do_action( 'delete_option', $option );
</span><del>-        $result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $option) );
</del><ins>+        $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) );
</ins><span class="cx">         if ( ! defined( 'WP_INSTALLING' ) ) {
</span><span class="cx">                 if ( 'yes' == $row->autoload ) {
</span><span class="cx">                         $alloptions = wp_load_alloptions();
</span><span class="lines">@@ -857,7 +857,7 @@
</span><span class="cx">                 $cache_key = "{$wpdb->siteid}:$option";
</span><span class="cx">                 wp_cache_delete( $cache_key, 'site-options' );
</span><span class="cx">
</span><del>-                $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) );
</del><ins>+                $result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $wpdb->siteid ) );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( $result ) {
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/post.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -2053,7 +2053,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         do_action( 'delete_post', $postid );
</span><del>-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
</del><ins>+        $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
</ins><span class="cx">         do_action( 'deleted_post', $postid );
</span><span class="cx">
</span><span class="cx">         if ( 'page' == $post->post_type ) {
</span><span class="lines">@@ -3810,7 +3810,7 @@
</span><span class="cx">         wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
</span><span class="cx">         wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
</span><span class="cx">
</span><del>-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id ));
</del><ins>+        $wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_thumbnail_id' , 'meta_value' => $post_id ) );
</ins><span class="cx">
</span><span class="cx">         $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
</span><span class="cx">         if ( ! empty( $comment_ids ) ) {
</span><span class="lines">@@ -3829,7 +3829,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         do_action( 'delete_post', $post_id );
</span><del>-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));
</del><ins>+        $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
</ins><span class="cx">         do_action( 'deleted_post', $post_id );
</span><span class="cx">
</span><span class="cx">         $uploadpath = wp_upload_dir();
</span></span></pre></div>
<a id="trunkwpincludestaxonomyphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/taxonomy.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/taxonomy.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/taxonomy.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -1802,12 +1802,12 @@
</span><span class="cx">                 clean_object_term_cache( $objects, $object_type );
</span><span class="cx">
</span><span class="cx">         do_action( 'delete_term_taxonomy', $tt_id );
</span><del>-        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id ) );
</del><ins>+        $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
</ins><span class="cx">         do_action( 'deleted_term_taxonomy', $tt_id );
</span><span class="cx">
</span><span class="cx">         // Delete the term if no taxonomies use it.
</span><span class="cx">         if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
</span><del>-                $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );
</del><ins>+                $wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) );
</ins><span class="cx">
</span><span class="cx">         clean_term_cache($term, $taxonomy);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludeswpdbphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/wp-db.php (20286 => 20287)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/wp-db.php        2012-03-24 14:07:12 UTC (rev 20286)
+++ trunk/wp-includes/wp-db.php        2012-03-24 15:24:31 UTC (rev 20287)
</span><span class="lines">@@ -404,9 +404,10 @@
</span><span class="cx">          * Keys are column names, values are format types: 'ID' => '%d'
</span><span class="cx">          *
</span><span class="cx">          * @since 2.8.0
</span><del>-         * @see wpdb:prepare()
-         * @see wpdb:insert()
-         * @see wpdb:update()
</del><ins>+         * @see wpdb::prepare()
+         * @see wpdb::insert()
+         * @see wpdb::update()
+         * @see wpdb::delete()
</ins><span class="cx">          * @see wp_set_wpdb_vars()
</span><span class="cx">          * @access public
</span><span class="cx">          * @var array
</span><span class="lines">@@ -1272,6 +1273,50 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><ins>+         * Delete a row in the table
+         *
+         * <code>
+         * wpdb::delete( 'table', array( 'ID' => 1 ) )
+         * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) )
+         * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ), 1 )
+         * </code>
+         *
+         * @since 2.5.0
+         * @see wpdb::prepare()
+         * @see wpdb::$field_types
+         * @see wp_set_wpdb_vars()
+         *
+         * @param string $table table name
+         * @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 unless otherwise specified in wpdb::$field_types.
+         * @return int|false The number of rows updated, or false on error.
+         */
+        function delete( $table, $where, $where_format = null ) {
+                if ( ! is_array( $where ) )
+                        return false;
+
+                $bits = $wheres = array();
+
+                $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 ) );
+        }
+
+
+        /**
</ins><span class="cx">          * Retrieve one variable from the database.
</span><span class="cx">          *
</span><span class="cx">          * Executes a SQL query and returns the value from the SQL result.
</span></span></pre>
</div>
</div>
</body>
</html>