Make WordPress Core


Ignore:
Timestamp:
05/24/2004 08:22:18 AM (21 years ago)
Author:
saxmatt
Message:

Giant commit, sorry mailing list people. Move all table names to new $wpdb versions. Works but the whole app needs thorough testing now.

File:
1 edited

Legend:

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

    r1328 r1355  
    22
    33function get_the_category() {
    4     global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache;
     4    global $post, $wpdb, $category_cache;
    55    if ($category_cache[$post->ID]) {
    66        return $category_cache[$post->ID];
     
    88        $categories = $wpdb->get_results("
    99            SELECT category_id, cat_name, category_nicename, category_description, category_parent
    10             FROM  $tablecategories, $tablepost2cat
    11             WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID
     10            FROM  $wpdb->categories, $wpdb->post2cat
     11            WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $post->ID
    1212            ");
    1313   
     
    1717
    1818function get_category_link($echo = false, $category_id, $category_nicename) {
    19     global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $cache_categories;
     19    global $wpdb, $post, $querystring_start, $querystring_equal, $cache_categories;
    2020    $cat_ID = $category_id;
    2121    $permalink_structure = get_settings('permalink_structure');
     
    124124
    125125function get_the_category_by_ID($cat_ID) {
    126     global $tablecategories, $cache_categories, $wpdb;
     126    global $cache_categories, $wpdb;
    127127    if ( !$cache_categories[$cat_ID] ) {
    128         $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'");
     128        $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
    129129        $cache_categories[$cat_ID]->cat_name = $cat_name;
    130130    } else {
     
    135135
    136136function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
    137     global $tablecategories, $cache_categories;
    138     $chain = "";
     137    global $cache_categories;
     138    $chain = '';
    139139    $parent = $cache_categories[$id];
    140140    if ($nicename) {
     
    153153
    154154function get_category_children($id, $before = '/', $after = '') {
    155     global $tablecategories, $cache_categories;
     155    global $cache_categories;
    156156    $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
    157157    $chain = '';
     
    185185
    186186function category_description($category = 0) {
    187     global $cat, $wpdb, $tablecategories, $cache_categories;
     187    global $cat, $wpdb, $cache_categories;
    188188    if (!$category) $category = $cat;
    189189    $category_description = $cache_categories[$category]->category_description;
     
    196196        $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
    197197        $selected=0, $hide=0) {
    198     global $tablecategories, $tableposts, $tablepost2cat, $wpdb;
     198    global $wpdb;
    199199    global $querystring_start, $querystring_equal, $querystring_separator;
    200200    if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/' . get_settings('blogfilename');
     
    204204    $query = "
    205205        SELECT cat_ID, cat_name, category_nicename,category_parent,
    206         COUNT($tablepost2cat.post_id) AS cat_count,
     206        COUNT($wpdb->post2cat.post_id) AS cat_count,
    207207        DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
    208         FROM $tablecategories LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
    209         LEFT JOIN $tableposts ON (ID = post_id)
     208        FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
     209        LEFT JOIN $wpdb->posts ON (ID = post_id)
    210210        WHERE cat_ID > 0
    211211        ";
     
    266266
    267267function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '') {
    268     global $tablecategories, $tableposts, $tablepost2cat, $wpdb, $category_posts;
     268    global $wpdb, $category_posts;
    269269    global $querystring_start, $querystring_equal, $querystring_separator;
    270270    // Optiondates now works
     
    288288        $query  = "
    289289            SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
    290             FROM $tablecategories
     290            FROM $wpdb->categories
    291291            WHERE cat_ID > 0 $exclusions
    292292            ORDER BY $sort_column $sort_order";
     
    296296    if (!count($category_posts)) {
    297297        $cat_counts = $wpdb->get_results("  SELECT cat_ID,
    298         COUNT($tablepost2cat.post_id) AS cat_count
    299         FROM $tablecategories
    300         INNER JOIN $tablepost2cat ON (cat_ID = category_id)
    301         INNER JOIN $tableposts ON (ID = post_id)
     298        COUNT($wpdb->post2cat.post_id) AS cat_count
     299        FROM $wpdb->categories
     300        INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
     301        INNER JOIN $wpdb->posts ON (ID = post_id)
    302302        WHERE post_status = 'publish' $exclusions
    303303        GROUP BY category_id");
     
    312312        $cat_dates = $wpdb->get_results("   SELECT cat_ID,
    313313        DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
    314         FROM $tablecategories
    315         LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
    316         LEFT JOIN $tableposts ON (ID = post_id)
     314        FROM $wpdb->categories
     315        LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
     316        LEFT JOIN $wpdb->posts ON (ID = post_id)
    317317        WHERE post_status = 'publish' $exclusions
    318318        GROUP BY category_id");
Note: See TracChangeset for help on using the changeset viewer.