Make WordPress Core


Ignore:
Timestamp:
05/24/2004 08:22:18 AM (20 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-admin/admin-functions.php

    r1340 r1355  
    2020
    2121function get_nested_categories($default = 0) {
    22  global $post_ID, $tablecategories, $tablepost2cat, $mode, $wpdb;
     22 global $post_ID, $mode, $wpdb;
    2323
    2424 if ($post_ID) {
    2525   $checked_categories = $wpdb->get_col("
    2626     SELECT category_id
    27      FROM  $tablecategories, $tablepost2cat
    28      WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = '$post_ID'
     27     FROM  $wpdb->categories, $wpdb->post2cat
     28     WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
    2929     ");
    3030 } else {
     
    3232 }
    3333
    34  $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY category_parent DESC, cat_name ASC");
     34 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY category_parent DESC, cat_name ASC");
    3535 $result = array();
    3636 foreach($categories as $category) {
     
    6767// Dandy new recursive multiple category stuff.
    6868function cat_rows($parent = 0, $level = 0, $categories = 0) {
    69     global $wpdb, $tablecategories, $tablepost2cat, $bgcolor;
     69    global $wpdb, $bgcolor;
    7070    if (!$categories) {
    71         $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
     71        $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    7272    }
    7373    if ($categories) {
    7474        foreach ($categories as $category) {
    7575            if ($category->category_parent == $parent) {
    76                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID");
     76                $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    7777                $pad = str_repeat('— ', $level);
    7878
     
    9292
    9393function wp_dropdown_cats($currentcat, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
    94     global $wpdb, $tablecategories, $tablepost2cat, $bgcolor;
     94    global $wpdb, $bgcolor;
    9595    if (!$categories) {
    96         $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
     96        $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    9797    }
    9898    if ($categories) {
    9999        foreach ($categories as $category) { if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    100             $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID");
     100            $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    101101            $pad = str_repeat('– ', $level);
    102102            echo "\n\t<option value='$category->cat_ID'";
     
    200200// Some postmeta stuff
    201201function has_meta($postid) {
    202     global $wpdb, $tablepostmeta;
     202    global $wpdb;
    203203
    204204    return $wpdb->get_results("
    205205        SELECT meta_key, meta_value, meta_id, post_id
    206         FROM $tablepostmeta
     206        FROM $wpdb->postmeta
    207207        WHERE post_id = '$postid'
    208208        ORDER BY meta_key,meta_id",ARRAY_A);
     
    241241// Get a list of previously defined keys
    242242function get_meta_keys() {
    243     global $wpdb, $tablepostmeta;
     243    global $wpdb;
    244244   
    245245    $keys = $wpdb->get_col("
    246246        SELECT meta_key
    247         FROM $tablepostmeta
     247        FROM $wpdb->postmeta
    248248        GROUP BY meta_key
    249249        ORDER BY meta_key");
     
    253253
    254254function meta_form() {
    255     global $wpdb, $tablepostmeta;
     255    global $wpdb;
    256256    $keys = $wpdb->get_col("
    257257        SELECT meta_key
    258         FROM $tablepostmeta
     258        FROM $wpdb->postmeta
    259259        GROUP BY meta_key
    260260        ORDER BY meta_id DESC
     
    290290
    291291function add_meta($post_ID) {
    292     global $wpdb, $tablepostmeta;
     292    global $wpdb;
    293293   
    294294    $metakeyselect = $wpdb->escape( stripslashes( trim($_POST['metakeyselect']) ) );
     
    307307
    308308        $result = $wpdb->query("
    309                 INSERT INTO $tablepostmeta
     309                INSERT INTO $wpdb->postmeta
    310310                (post_id,meta_key,meta_value)
    311311                VALUES ('$post_ID','$metakey','$metavalue')
     
    315315
    316316function delete_meta($mid) {
    317     global $wpdb, $tablepostmeta;
    318 
    319     $result = $wpdb->query("DELETE FROM $tablepostmeta WHERE meta_id = '$mid'");
     317    global $wpdb;
     318
     319    $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
    320320}
    321321
    322322function update_meta($mid, $mkey, $mvalue) {
    323     global $wpdb, $tablepostmeta;
    324 
    325     return $wpdb->query("UPDATE $tablepostmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
     323    global $wpdb;
     324
     325    return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
    326326}
    327327
Note: See TracChangeset for help on using the changeset viewer.