changeset 1168 | 277a9cdead3e |
parent 1108 | c1be67a50d81 |
child 1173 | b5b8e7ab0914 |
1167:3c73e1b6d33f | 1168:277a9cdead3e |
---|---|
985 return $cache[$pathskey]; |
985 return $cache[$pathskey]; |
986 |
986 |
987 $page_id_db = $db->escape($page_id); |
987 $page_id_db = $db->escape($page_id); |
988 $namespace_db = $db->escape($namespace); |
988 $namespace_db = $db->escape($namespace); |
989 |
989 |
990 $q = $db->sql_query('SELECT p.*, COUNT(ca.comment_id) AS comments_approved, COUNT(cu.comment_id) AS comments_unapproved, COUNT(cs.comment_id) AS comments_spam' |
990 $q = $db->sql_query('SELECT p.*' |
991 . ' FROM ' . table_prefix . "pages AS p\n" |
991 . ' FROM ' . table_prefix . "pages AS p\n" |
992 . " LEFT JOIN " . table_prefix . "comments AS ca\n" |
|
993 . " ON ( (ca.approved = " . COMMENT_APPROVED . " AND ca.page_id = p.urlname ) OR ca.comment_id IS NULL)\n" |
|
994 . " LEFT JOIN " . table_prefix . "comments AS cu\n" |
|
995 . " ON ( (cu.approved = " . COMMENT_UNAPPROVED . " AND cu.page_id = p.urlname ) OR cu.comment_id IS NULL)\n" |
|
996 . " LEFT JOIN " . table_prefix . "comments AS cs\n" |
|
997 . " ON ( (cs.approved = " . COMMENT_SPAM . " AND cs.page_id = p.urlname ) OR cs.comment_id IS NULL)\n" |
|
998 . " WHERE p.urlname = '$page_id_db' AND p.namespace = '$namespace_db'\n" |
992 . " WHERE p.urlname = '$page_id_db' AND p.namespace = '$namespace_db'\n" |
999 . " GROUP BY p.urlname, p.name, p.namespace, p.page_order, p.special, p.visible, p.protected, p.wiki_mode, p.comments_on, p.delvotes, p.delvote_ips, p.page_format, p.password;"); |
993 . " GROUP BY p.urlname, p.name, p.namespace, p.page_order, p.special, p.visible, p.protected, p.wiki_mode, p.comments_on, p.delvotes, p.delvote_ips, p.page_format, p.password;"); |
1000 |
994 |
1001 if ( !$q ) |
995 if ( !$q ) |
1002 $db->_die(); |
996 $db->_die(); |
1003 |
997 |
1004 if ( $db->numrows() < 1 ) |
998 if ( $db->numrows() < 1 ) |
1007 $cache[$pathskey] = false; |
1001 $cache[$pathskey] = false; |
1008 return false; |
1002 return false; |
1009 } |
1003 } |
1010 |
1004 |
1011 $row = $db->fetchrow(); |
1005 $row = $db->fetchrow(); |
1006 |
|
1007 // Get comment counts |
|
1008 $q = $db->sql_query('SELECT approved FROM ' . table_prefix . "comments WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';"); |
|
1009 // yay parallel assignment |
|
1010 $row['comments_approved'] = $row['comments_unapproved'] = $row['comments_spam'] = 0; |
|
1011 while ( $commentrow = $db->fetchrow() ) |
|
1012 switch($commentrow['approved']) |
|
1013 { |
|
1014 case COMMENT_APPROVED: |
|
1015 default: |
|
1016 $row['comments_approved']++; |
|
1017 break; |
|
1018 case COMMENT_UNAPPROVED: |
|
1019 $row['comments_unapproved']++; |
|
1020 break; |
|
1021 case COMMENT_SPAM: |
|
1022 $row['comments_spam']++; |
|
1023 break; |
|
1024 } |
|
1025 |
|
1012 $cache[$pathskey] = $row; |
1026 $cache[$pathskey] = $row; |
1013 return $row; |
1027 return $row; |
1014 } |
1028 } |
1015 } |
1029 } |
1016 |
1030 |