Make WordPress Core

Changeset 3012


Ignore:
Timestamp:
11/07/2005 11:09:09 PM (21 years ago)
Author:
ryan
Message:

Add LIMIT 1 to some of our gets.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r3011 r3012  
    558558                        $_post = & $post_cache[$post];
    559559                else {
    560                         $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post'";
     560                        $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1";
    561561                        $post_cache[$post] = & $wpdb->get_row($query);
    562562                        $_post = & $post_cache[$post];
     
    597597                        // Got it.
    598598                } else {
    599                         $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page'";
     599                        $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1";
    600600                        $_page = & $wpdb->get_row($query);
    601601                        wp_cache_add($_page->ID, $_page, 'pages');
     
    641641        } else {
    642642                if ( ! $_category = wp_cache_get($category, 'category') ) {
    643                         $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category'");
     643                        $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
    644644                        wp_cache_add($category, $_category, 'category');
    645645                }
     
    676676        } else {
    677677                if ( !isset($comment_cache[$comment]) ) {
    678                         $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment'");
     678                        $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
    679679                        $comment_cache[$comment->comment_ID] = & $_comment;
    680680                } else {
  • trunk/wp-includes/pluggable-functions.php

    r3011 r3012  
    3838                return $user;
    3939
    40         if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id'") )
     40        if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id' LIMIT 1") )
    4141                return false;
    4242
Note: See TracChangeset for help on using the changeset viewer.