Make WordPress Core


Ignore:
Timestamp:
03/06/2009 04:27:51 AM (17 years ago)
Author:
ryan
Message:

Use wpdb::insert() and update(). Props DD32. see #6836

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r10681 r10730  
    10211021    global $wpdb;
    10221022
     1023    $status = '0';
    10231024    switch ( $comment_status ) {
    10241025        case 'hold':
    1025             $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID = %d LIMIT 1", $comment_id);
     1026            $status = '0';
    10261027            break;
    10271028        case 'approve':
    1028             $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID = %d LIMIT 1", $comment_id);
     1029            $status = '1';
    10291030            if ( get_option('comments_notify') ) {
    10301031                $comment = get_comment($comment_id);
     
    10331034            break;
    10341035        case 'spam':
    1035             $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id);
     1036            $status = 'spam';
    10361037            break;
    10371038        case 'delete':
     
    10421043    }
    10431044
    1044     if ( !$wpdb->query($query) ) {
     1045    if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
    10451046        if ( $wp_error )
    10461047            return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
     
    13511352    $pinged  = get_pung($post_id);
    13521353    if ( empty($to_ping) ) {
    1353         $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = %d", $post_id) );
     1354        $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) );
    13541355        return;
    13551356    }
Note: See TracChangeset for help on using the changeset viewer.