Make WordPress Core

Changeset 189


Ignore:
Timestamp:
06/07/2003 11:19:42 PM (23 years ago)
Author:
mikelittle
Message:

Converted to ezsql

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2archives.php

    r99 r189  
    55require_once('b2config.php');
    66require_once($abspath.$b2inc.'/b2functions.php');
    7 
    8 dbconnect();
    97
    108// this is what will separate your archive links
     
    5351
    5452if ($archive_mode == 'monthly') {
    55     $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
     53    $arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
    5654    $querycount++;
    57     $arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
    58     while($arc_row = mysql_fetch_array($arc_result)) {
    59         $arc_year  = $arc_row['YEAR(post_date)'];
    60         $arc_month = $arc_row['MONTH(post_date)'];
     55    $arc_results = $wpdb->get_results($arc_sql);
     56    foreach ($arc_results as $arc_row) {
     57        $arc_year  = $arc_row->yr;
     58        $arc_month = $arc_row->mn;
    6159        echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).'">';
    6260        echo $month[zeroise($arc_month,2)].' '.$arc_year;
     
    6462    }
    6563} elseif ($archive_mode == 'daily') {
    66     $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
     64    $arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn, DAYOFMONTH(post_date) as dom FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
    6765    $querycount++;
    68     $arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
    69     while($arc_row = mysql_fetch_array($arc_result)) {
    70         $arc_year  = $arc_row['YEAR(post_date)'];
    71         $arc_month = $arc_row['MONTH(post_date)'];
    72         $arc_dayofmonth = $arc_row['DAYOFMONTH(post_date)'];
     66    $arc_results = $wpdb->get_results($arc_sql);
     67    foreach ($arc_results as $arc_row) {
     68        $arc_year  = $arc_row->yr;
     69        $arc_month = $arc_row->mn;
     70        $arc_dayofmonth = $arc_row->dom;
    7371        echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2).'">';
    7472        echo mysql2date($archive_day_date_format, $arc_year.'-'.zeroise($arc_month,2).'-'.zeroise($arc_dayofmonth,2).' 00:00:00');
     
    7977        $start_of_week = 1;
    8078    }
    81     $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
     79    $arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn, DAYOFMONTH(post_date) AS dom, WEEK(post_date) AS wk FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
    8280    $querycount++;
    83     $arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
     81    $arc_results = $wpdb->get_results($arc_sql);
    8482    $arc_w_last = '';
    85     while($arc_row = mysql_fetch_array($arc_result)) {
    86         $arc_year = $arc_row['YEAR(post_date)'];
    87         $arc_w = $arc_row['WEEK(post_date)'];
     83    foreach ($arc_results as $arc_row) {
     84        $arc_year = $arc_row->yr;
     85        $arc_w = $arc_row->wk;
    8886        if ($arc_w != $arc_w_last) {
    8987            $arc_w_last = $arc_w;
    90             $arc_ymd = $arc_year.'-'.zeroise($arc_row['MONTH(post_date)'],2).'-' .zeroise($arc_row['DAYOFMONTH(post_date)'],2);
     88            $arc_ymd = $arc_year.'-'.zeroise($arc_row->mn,2).'-' .zeroise($arc_row->dom,2);
    9189            $arc_week = get_weekstartend($arc_ymd, $start_of_week);
    9290            $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
     
    9896    }
    9997} elseif ($archive_mode == 'postbypost') {
    100     $requestarc = " SELECT ID,post_date,post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
     98    $requestarc = " SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC";
    10199    $querycount++;
    102     $resultarc = mysql_query($requestarc);
    103     while($row=mysql_fetch_object($resultarc)) {
     100    $resultarc = $wpdb->get_results($requestarc);
     101    foreach ($resultarc as $row) {
    104102        if ($row->post_date != '0000-00-00 00:00:00') {
    105103            echo "<li><a href=\"$archive_link_p".$row->ID.'">';
Note: See TracChangeset for help on using the changeset viewer.