WordPress.org

Make WordPress Core

Changeset 10731


Ignore:
Timestamp:
03/06/2009 05:06:15 AM (9 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
4 edited

Legend:

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

    r10680 r10731  
    217217
    218218    $comment_id = absint( $_POST['comment_ID'] );
    219     $comment_post_id = absint( $_POST['comment_post_id'] );
     219    $comment_post_id = absint( $_POST['comment_post_ID'] );
    220220
    221221    check_admin_referer( 'update-comment_' . $comment_id );
  • trunk/wp-admin/update-links.php

    r9051 r10731  
    4848$returns = explode("\n", $body);
    4949
    50 foreach ($returns as $return) :
     50foreach ($returns as $return) {
    5151    $time = substr($return, 0, 19);
    5252    $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
    53     $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
    54 endforeach;
     53    $wdpdb->update( $wpdb->links, array('link_updated' => $time), array('link_url' => $uri) );
     54}
    5555
    5656?>
  • trunk/wp-includes/comment.php

    r10730 r10731  
    881881        $comment_type = '';
    882882
    883     $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->comments
    884     (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_karma, comment_approved, comment_agent, comment_type, comment_parent, user_id)
    885     VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %d, %d)",
    886     $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_karma, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id) );
     883    $data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
     884    $wpdb->insert($wpdb->comments, $data);
    887885
    888886    $id = (int) $wpdb->insert_id;
    889887
    890     if ( $comment_approved == 1)
     888    if ( $comment_approved == 1 )
    891889        wp_update_comment_count($comment_post_ID);
    892890
     
    10811079
    10821080    // Escape data pulled from DB.
    1083     foreach ( (array) $comment as $key => $value )
    1084         $comment[$key] = $wpdb->escape($value);
     1081    $comment = $wpdb->escape($comment);
    10851082
    10861083    // Merge old and new fields with new fields overwriting old ones.
     
    11031100        $comment_approved = 1;
    11041101
    1105     $wpdb->query( $wpdb->prepare("UPDATE $wpdb->comments SET
    1106             comment_content      = %s,
    1107             comment_author       = %s,
    1108             comment_author_email = %s,
    1109             comment_approved     = %s,
    1110             comment_karma        = %d,
    1111             comment_author_url   = %s,
    1112             comment_date         = %s,
    1113             comment_date_gmt     = %s
    1114         WHERE comment_ID = %d",
    1115             $comment_content,
    1116             $comment_author,
    1117             $comment_author_email,
    1118             $comment_approved,
    1119             $comment_karma,
    1120             $comment_author_url,
    1121             $comment_date,
    1122             $comment_date_gmt,
    1123             $comment_ID) );
     1102    $data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt');
     1103    $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
    11241104
    11251105    $rval = $wpdb->rows_affected;
     
    12201200    $old = (int) $post->comment_count;
    12211201    $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
    1222     $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_count = %d WHERE ID = %d", $new, $post_id) );
     1202    $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
    12231203
    12241204    if ( 'page' == $post->post_type )
  • trunk/wp-settings.php

    r10726 r10731  
    255255    'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    256256    'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    257     'user_status' => '%d', 'umeta_id' => '%d');
     257    'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
    258258
    259259require_wp_db();
Note: See TracChangeset for help on using the changeset viewer.