Changeset 20287
- Timestamp:
- 03/24/2012 03:24:31 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/bookmark.php
r20256 r20287 85 85 wp_delete_object_term_relationships( $link_id, 'link_category' ); 86 86 87 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d",$link_id ) );87 $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) ); 88 88 89 89 do_action( 'deleted_link', $link_id ); -
trunk/wp-admin/includes/ms.php
r20199 r20287 90 90 } 91 91 92 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 92 $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) ); 93 93 94 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); 94 95 $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); … … 159 160 } 160 161 161 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d",$id ) );162 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d",$id ) );162 $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); 163 $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) ); 163 164 164 165 clean_user_cache( $id ); -
trunk/wp-admin/includes/upgrade.php
r20148 r20287 301 301 // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. 302 302 if ( !is_super_admin( $user_id ) && $user_id != 1 ) 303 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );303 $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); 304 304 } 305 305 } -
trunk/wp-admin/includes/user.php
r19712 r20287 267 267 // FINALLY, delete user 268 268 if ( !is_multisite() ) { 269 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );270 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );269 $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) ); 270 $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); 271 271 } else { 272 272 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels 273 $wpdb-> query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'");273 $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id , 'meta_key' => $level_key ) ); 274 274 } 275 275 -
trunk/wp-includes/comment.php
r20127 r20287 989 989 } 990 990 991 if ( ! $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )991 if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) 992 992 return false; 993 993 do_action('deleted_comment', $comment_id); -
trunk/wp-includes/meta.php
r19712 r20287 490 490 491 491 // Run the query, will return true if deleted, false otherwise 492 $result = (bool) $wpdb-> query( $wpdb->prepare( "DELETE FROM $table WHERE $id_column = %d LIMIT 1;",$meta_id ) );492 $result = (bool) $wpdb->delete( $table, array( $id_column => $meta_id ) ); 493 493 494 494 // Clear the caches. -
trunk/wp-includes/ms-functions.php
r20101 r20287 497 497 // If registered more than two days ago, cancel registration and let this signup go through. 498 498 if ( $diff > 172800 ) 499 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_login = %s", $user_name) );499 $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) ); 500 500 else 501 501 $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); … … 510 510 // If registered more than two days ago, cancel registration and let this signup go through. 511 511 if ( $diff > 172800 ) 512 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_email = %s", $user_email) );512 $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) ); 513 513 else 514 514 $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.')); … … 613 613 // If registered more than two days ago, cancel registration and let this signup go through. 614 614 if ( $diff > 172800 ) 615 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) );615 $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) ); 616 616 else 617 617 $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); … … 1161 1161 1162 1162 // remove all perms 1163 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'user_level') ); 1164 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'capabilities') ); 1163 $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) ); 1164 1165 $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) ); 1165 1166 1166 1167 $wpdb->suppress_errors( false ); -
trunk/wp-includes/option.php
r19602 r20287 368 368 return false; 369 369 do_action( 'delete_option', $option ); 370 $result = $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $option) );370 $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); 371 371 if ( ! defined( 'WP_INSTALLING' ) ) { 372 372 if ( 'yes' == $row->autoload ) { … … 858 858 wp_cache_delete( $cache_key, 'site-options' ); 859 859 860 $result = $wpdb-> query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option,$wpdb->siteid ) );860 $result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $wpdb->siteid ) ); 861 861 } 862 862 -
trunk/wp-includes/post.php
r20271 r20287 2054 2054 2055 2055 do_action( 'delete_post', $postid ); 2056 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));2056 $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 2057 2057 do_action( 'deleted_post', $postid ); 2058 2058 … … 3811 3811 wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type)); 3812 3812 3813 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id ));3813 $wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_thumbnail_id' , 'meta_value' => $post_id ) ); 3814 3814 3815 3815 $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id )); … … 3830 3830 3831 3831 do_action( 'delete_post', $post_id ); 3832 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));3832 $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); 3833 3833 do_action( 'deleted_post', $post_id ); 3834 3834 -
trunk/wp-includes/taxonomy.php
r20023 r20287 1803 1803 1804 1804 do_action( 'delete_term_taxonomy', $tt_id ); 1805 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d",$tt_id ) );1805 $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) ); 1806 1806 do_action( 'deleted_term_taxonomy', $tt_id ); 1807 1807 1808 1808 // Delete the term if no taxonomies use it. 1809 1809 if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) 1810 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );1810 $wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) ); 1811 1811 1812 1812 clean_term_cache($term, $taxonomy); -
trunk/wp-includes/wp-db.php
r19773 r20287 405 405 * 406 406 * @since 2.8.0 407 * @see wpdb:prepare() 408 * @see wpdb:insert() 409 * @see wpdb:update() 407 * @see wpdb::prepare() 408 * @see wpdb::insert() 409 * @see wpdb::update() 410 * @see wpdb::delete() 410 411 * @see wp_set_wpdb_vars() 411 412 * @access public … … 1271 1272 return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) ); 1272 1273 } 1274 1275 /** 1276 * Delete a row in the table 1277 * 1278 * <code> 1279 * wpdb::delete( 'table', array( 'ID' => 1 ) ) 1280 * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) ) 1281 * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ), 1 ) 1282 * </code> 1283 * 1284 * @since 2.5.0 1285 * @see wpdb::prepare() 1286 * @see wpdb::$field_types 1287 * @see wp_set_wpdb_vars() 1288 * 1289 * @param string $table table name 1290 * @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". 1291 * @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. 1292 * @return int|false The number of rows updated, or false on error. 1293 */ 1294 function delete( $table, $where, $where_format = null ) { 1295 if ( ! is_array( $where ) ) 1296 return false; 1297 1298 $bits = $wheres = array(); 1299 1300 $where_formats = $where_format = (array) $where_format; 1301 1302 foreach ( array_keys( $where ) as $field ) { 1303 if ( !empty( $where_format ) ) { 1304 $form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0]; 1305 } elseif ( isset( $this->field_types[ $field ] ) ) { 1306 $form = $this->field_types[ $field ]; 1307 } else { 1308 $form = '%s'; 1309 } 1310 1311 $wheres[] = "$field = $form"; 1312 } 1313 1314 $sql = "DELETE FROM $table WHERE " . implode( ' AND ', $wheres ); 1315 return $this->query( $this->prepare( $sql, $where ) ); 1316 } 1317 1273 1318 1274 1319 /**
Note: See TracChangeset
for help on using the changeset viewer.