Reducing queries and forward thinking database fields.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt
2004-04-26 23:54:52 +00:00
parent f8e2f4f2f4
commit 51335f97bb
3 changed files with 11 additions and 23 deletions

View File

@@ -30,8 +30,9 @@ function clean_url($url) {
}
function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
global $id, $comment, $tablecomments, $wpdb;
if ('' == $number) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
global $id, $comment, $tablecomments, $wpdb, $comment_count_cache;
if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
else $number = $comment_count_cache["$id"];
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {