Make WordPress Core


Ignore:
Timestamp:
04/26/2004 11:54:52 PM (21 years ago)
Author:
saxmatt
Message:

Reducing queries and forward thinking database fields.

File:
1 edited

Legend:

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

    r1132 r1185  
    3131
    3232function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
    33     global $id, $comment, $tablecomments, $wpdb;
    34     if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
     33    global $id, $comment, $tablecomments, $wpdb, $comment_count_cache;
     34    if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
     35    else $number = $comment_count_cache["$id"];
    3536    if ($number == 0) {
    3637        $blah = $zero;
Note: See TracChangeset for help on using the changeset viewer.