Make WordPress Core

Changeset 282


Ignore:
Timestamp:
07/30/2003 11:44:08 PM (23 years ago)
Author:
mikelittle
Message:

Removed mysql direct calls

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2functions.php

    r271 r282  
    520520}
    521521
    522 function get_postdata2($postid=0) { // less flexible, but saves mysql queries
     522function get_postdata2($postid=0) { // less flexible, but saves DB queries
    523523    global $post;
    524524    $postdata = array (
     
    538538}
    539539
    540 function get_commentdata($comment_ID,$no_cache=0) { // less flexible, but saves mysql queries
     540function get_commentdata($comment_ID,$no_cache=0) { // less flexible, but saves DB queries
    541541    global $postc,$id,$commentdata,$tablecomments,$querycount, $wpdb;
    542542    if ($no_cache) {
  • trunk/b2-include/b2template.functions.php

    r274 r282  
    718718
    719719function next_posts_link($label='Next Page >>', $max_page=0) {
    720     global $p, $paged, $result, $request, $posts_per_page, $what_to_show;
     720    global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb;
    721721    if ($what_to_show == 'paged') {
    722722        if (!$max_page) {
    723723            $nxt_request = $request;
     724            //if the query includes a limit clause, call it again without that
     725            //limit clause!
    724726            if ($pos = strpos(strtoupper($request), 'LIMIT')) {
    725727                $nxt_request = substr($request, 0, $pos);
    726728            }
    727             $nxt_result = mysql_query($nxt_request);
    728             $numposts = mysql_num_rows($nxt_result);
     729            $nxt_result = $wpdb->query($nxt_request);
     730            $numposts = $wpdb->num_rows;
    729731            $max_page = ceil($numposts / $posts_per_page);
    730732        }
    731         if (!$paged) $paged = 1;
     733        if (!$paged)
     734            $paged = 1;
    732735        $nextpage = intval($paged) + 1;
    733736        if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {
     
    775778
    776779function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Next Page >>') {
    777     global $p, $what_to_show, $request, $posts_per_page;
     780    global $p, $what_to_show, $request, $posts_per_page, $wpdb;
    778781    if (empty($p) && ($what_to_show == 'paged')) {
    779782        $nxt_request = $request;
     
    781784            $nxt_request = substr($request, 0, $pos);
    782785        }
    783         $nxt_result = mysql_query($nxt_request);
    784         $numposts = mysql_num_rows($nxt_result);
     786        $nxt_result = $wpdb->query($nxt_request);
     787        $numposts = $wpdb->num_rows;
    785788        $max_page = ceil($numposts / $posts_per_page);
    786789        if ($max_page > 1) {
  • trunk/wp-admin/b2categories.php

    r135 r282  
    4848    $cat_name=addslashes($HTTP_POST_VARS["cat_name"]);
    4949
    50     $query = "INSERT INTO $tablecategories (cat_ID,cat_name) VALUES ('0', '$cat_name')";
    51     $result = mysql_query($query) or die("Couldn't add category <b>$cat_name</b>");
     50    $wpdb->query("INSERT INTO $tablecategories (cat_ID,cat_name) VALUES ('0', '$cat_name')");
    5251   
    5352    header('Location: b2categories.php');
     
    6968    if ($user_level < 3)
    7069        die ('Cheatin&#8217; uh?');
    71    
    72     $query = "DELETE FROM $tablecategories WHERE cat_ID = $cat_ID";
    73     $result = mysql_query($query) or die("Couldn't delete category <b>$cat_name</b>".mysql_error());
    74    
    75     $query = "UPDATE $tableposts SET post_category='1' WHERE post_category='$cat_ID'";
    76     $result = mysql_query($query) or die("Couldn't reset category on posts where category was <b>$cat_name</b>");
     70
     71    $wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID");
     72    $wpdb->query("UPDATE $tableposts SET post_category='1' WHERE post_category='$cat_ID'");
    7773
    7874    header('Location: b2categories.php');
     
    114110    $cat_ID = addslashes($HTTP_POST_VARS["cat_ID"]);
    115111
    116     $query = "UPDATE $tablecategories SET cat_name='$cat_name' WHERE cat_ID = $cat_ID";
    117     $result = mysql_query($query) or die("Couldn't edit category <b>$cat_name</b>: ".mysql_error());
     112    $wpdb->query("UPDATE $tablecategories SET cat_name='$cat_name' WHERE cat_ID = $cat_ID");
    118113   
    119114    header('Location: b2categories.php');
  • trunk/wp-admin/b2edit.showposts.php

    r212 r282  
    149149    if ($archive_mode == "monthly") {
    150150        echo "<select name=\"m\" style=\"width:120px;\">";
    151         $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
    152151        $querycount++;
    153         $arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
    154         while($arc_row = mysql_fetch_array($arc_result)) {
     152        $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts ORDER BY post_date DESC",ARRAY_A);
     153        foreach ($arc_result as $arc_row) {
    155154            $arc_year  = $arc_row["YEAR(post_date)"];
    156155            $arc_month = $arc_row["MONTH(post_date)"];
     
    162161        echo "<select name=\"d\" style=\"width:120px;\">";
    163162        $archive_day_date_format = "Y/m/d";
    164         $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
    165163        $querycount++;
    166         $arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
    167         while($arc_row = mysql_fetch_array($arc_result)) {
     164        $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts ORDER BY post_date DESC", ARRAY_A);
     165        foreach ($arc_result as $arc_row) {
    168166            $arc_year  = $arc_row["YEAR(post_date)"];
    169167            $arc_month = $arc_row["MONTH(post_date)"];
     
    181179        $archive_week_end_date_format   = "Y/m/d";
    182180        $archive_week_separator = " - ";
    183         $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts ORDER BY post_date DESC";
    184181        $querycount++;
    185         $arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
     182        $arc_result=$wpdb->geT_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts ORDER BY post_date DESC", ARRAY_A);
    186183        $arc_w_last = '';
    187         while($arc_row = mysql_fetch_array($arc_result)) {
     184        foreach ($arc_result as $arc_row) {
    188185            $arc_year = $arc_row["YEAR(post_date)"];
    189186            $arc_w = $arc_row["WEEK(post_date)"];
     
    202199        echo '<input type="hidden" name="more" value="1" />';
    203200        echo '<select name="p" style="width:120px;">';
    204         $requestarc = " SELECT ID,post_date,post_title FROM $tableposts ORDER BY post_date DESC";
    205         $querycount++;
    206         $resultarc = mysql_query($requestarc);
    207         while($row=mysql_fetch_object($resultarc)) {
     201        $querycount++;
     202        $resultarc = $wpdb->get_results("SELECT ID,post_date,post_title FROM $tableposts ORDER BY post_date DESC");
     203        foreach ($resultarc as $row) {
    208204            if ($row->post_date != "0000-00-00 00:00:00") {
    209205                echo "<option value=\"".$row->ID."\">";
  • trunk/wp-admin/b2profile.php

    r239 r282  
    9797    $result = $wpdb->query($query);
    9898    if (!$result) {
    99         die ("<strong>ERROR</strong>: couldn't update your profile... please contact the <a href=\"mailto:$admin_email\">webmaster</a> !<br /><br />$query<br /><br />".mysql_error());
     99        die ("<strong>ERROR</strong>: couldn't update your profile... please contact the <a href=\"mailto:$admin_email\">webmaster</a> !<br /><br />$query<br /><br />");
    100100    }
    101101
Note: See TracChangeset for help on using the changeset viewer.