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-general.php

    r1301 r1355  
    9292
    9393function wp_title($sep = '»', $display = true) {
    94     global $wpdb, $tableposts, $tablecategories;
     94    global $wpdb;
    9595    global $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single;
    9696
     
    102102    }
    103103    if (!empty($category_name)) {
    104         $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
     104        $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"));
    105105    }
    106106
     
    137137
    138138function single_post_title($prefix = '', $display = true) {
    139     global $p, $name, $wpdb, $tableposts;
     139    global $p, $name, $wpdb;
    140140    if (intval($p) || '' != $name) {
    141141        if (!$p) {
    142             $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'");
     142            $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
    143143        }
    144144        $post_data = get_postdata($p);
     
    203203
    204204function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
    205     global $tableposts;
    206205    global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb;
    207206
     
    244243
    245244    if ('monthly' == $type) {
    246         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
     245        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    247246        if ($arcresults) {
    248247            $afterafter = $after;
     
    259258        }
    260259    } elseif ('daily' == $type) {
    261         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     260        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    262261        if ($arcresults) {
    263262            foreach ($arcresults as $arcresult) {
     
    270269    } elseif ('weekly' == $type) {
    271270    $start_of_week = get_settings('start_of_week');
    272         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     271        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    273272        $arc_w_last = '';
    274273        if ($arcresults) {
     
    289288        }
    290289    } elseif ('postbypost' == $type) {
    291         $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     290        $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    292291        if ($arcresults) {
    293292            foreach ($arcresults as $arcresult) {
     
    308307
    309308function get_calendar($daylength = 1) {
    310     global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $tableposts, $posts;
     309    global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
    311310
    312311    // Quick check. If we have no posts at all, abort!
    313312    if (!$posts) {
    314         $gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
     313        $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
    315314        if (!$gotsome)
    316315            return;
     
    350349    // Get the next and previous month and year with at least one post
    351350    $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    352             FROM $tableposts
     351            FROM $wpdb->posts
    353352            WHERE post_date < '$thisyear-$thismonth-01'
    354353            AND post_status = 'publish'
     
    356355                              LIMIT 1");
    357356    $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    358             FROM $tableposts
     357            FROM $wpdb->posts
    359358            WHERE post_date >  '$thisyear-$thismonth-01'
    360359            AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
     
    410409    // Get days with posts
    411410    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
    412             FROM $tableposts WHERE MONTH(post_date) = $thismonth
     411            FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
    413412            AND YEAR(post_date) = $thisyear
    414413            AND post_status = 'publish'
     
    434433    $ak_titles_for_day = array();
    435434    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
    436                                          ."FROM $tableposts "
     435                                         ."FROM $wpdb->posts "
    437436                                         ."WHERE YEAR(post_date) = '$thisyear' "
    438437                                         ."AND MONTH(post_date) = '$thismonth' "
Note: See TracChangeset for help on using the changeset viewer.