Changeset 1355

Show
Ignore:
Timestamp:
05/24/04 08:22:18 (4 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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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 
  • trunk/wp-admin/admin-header.php

    r1340 r1355  
    1515timer_start(); 
    1616 
    17 $dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1"); 
     17$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE 1=1"); 
    1818foreach ($dogs as $catt) { 
    1919    $cache_categories[$catt->cat_ID] = $catt; 
  • trunk/wp-admin/auth.php

    r1317 r1355  
    66function veriflog() { 
    77    global $cookiehash; 
    8     global $tableusers, $wpdb; 
     8    global $wpdb; 
    99 
    1010    if (!empty($_COOKIE['wordpressuser_' . $cookiehash])) { 
     
    2020        return false; 
    2121 
    22     $login = $wpdb->get_row("SELECT user_login, user_pass FROM $tableusers WHERE user_login = '$user_login'"); 
     22    $login = $wpdb->get_row("SELECT user_login, user_pass FROM $wpdb->users WHERE user_login = '$user_login'"); 
    2323 
    2424    if (!$login) { 
  • trunk/wp-admin/categories.php

    r1352 r1355  
    5252    $cat = intval($_POST['cat']); 
    5353 
    54     $wpdb->query("INSERT INTO $tablecategories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')"); 
     54    $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')"); 
    5555     
    5656    header('Location: categories.php?message=1#addcat'); 
     
    6868    $cat_name = get_catname($cat_ID); 
    6969    $cat_name = addslashes($cat_name); 
    70     $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = '$cat_ID'"); 
     70    $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); 
    7171    $cat_parent = $category->category_parent; 
    7272 
     
    7777        die (__('Cheatin&#8217; uh?')); 
    7878 
    79     $wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = '$cat_ID'"); 
    80     $wpdb->query("UPDATE $tablecategories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'"); 
    81     $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'"); 
     79    $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); 
     80    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'"); 
     81    $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'"); 
    8282 
    8383    header('Location: categories.php?message=2'); 
     
    8989    require_once ('admin-header.php'); 
    9090    $cat_ID = intval($_GET['cat_ID']); 
    91     $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = '$cat_ID'"); 
     91    $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); 
    9292    $cat_name = stripslashes($category->cat_name); 
    9393    ?> 
     
    130130    $category_description = $wpdb->escape(stripslashes($_POST['category_description'])); 
    131131 
    132     $wpdb->query("UPDATE $tablecategories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$cat' WHERE cat_ID = '$cat_ID'"); 
     132    $wpdb->query("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$cat' WHERE cat_ID = '$cat_ID'"); 
    133133     
    134134    header('Location: categories.php?message=3'); 
  • trunk/wp-admin/edit-comments.php

    r1271 r1355  
    4646    foreach ($delete_comments as $comment) { // Check the permissions on each 
    4747        $comment = intval($comment); 
    48         $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $tablecomments WHERE comment_ID = $comment"); 
    49         $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $post_id")); 
     48        $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); 
     49        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id")); 
    5050        if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) { 
    51             $wpdb->query("DELETE FROM $tablecomments WHERE comment_ID = $comment"); 
     51            $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $comment"); 
    5252            ++$i; 
    5353        } 
     
    5858if (isset($_GET['s'])) { 
    5959    $s = $wpdb->escape($_GET['s']); 
    60     $comments = $wpdb->get_results("SELECT * FROM $tablecomments  WHERE 
     60    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments  WHERE 
    6161        comment_author LIKE '%$s%' OR 
    6262        comment_author_email LIKE '%$s%' OR 
     
    6666        ORDER BY comment_date DESC"); 
    6767} else { 
    68     $comments = $wpdb->get_results("SELECT * FROM $tablecomments ORDER BY comment_date DESC LIMIT 20"); 
     68    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments ORDER BY comment_date DESC LIMIT 20"); 
    6969} 
    7070if ('view' == $mode) { 
     
    7272        echo '<ol>'; 
    7373        foreach ($comments as $comment) { 
    74         $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID")); 
     74        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 
    7575            $comment_status = wp_get_comment_status($comment->comment_ID); 
    7676            if ('unapproved' == $comment_status) { 
     
    9090            } // end if any comments to show 
    9191            // Get post title 
    92             $post_title = $wpdb->get_var("SELECT post_title FROM $tableposts WHERE ID = $comment->comment_post_ID"); 
     92            $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"); 
    9393            $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 
    9494            ?> <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), stripslashes($post_title)); ?></a> | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p> 
     
    120120  </tr>'; 
    121121        foreach ($comments as $comment) { 
    122         $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID")); 
     122        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 
    123123        $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee'; 
    124124?> 
  • trunk/wp-admin/edit.php

    r1271 r1355  
    1313<?php 
    1414get_currentuserinfo(); 
    15 $drafts = $wpdb->get_results("SELECT ID, post_title FROM $tableposts WHERE post_status = 'draft' AND post_author = $user_ID"); 
     15$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID"); 
    1616if ($drafts) { 
    1717    ?>  
     
    4848    <select name='m'> 
    4949    <?php 
    50         $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $tableposts ORDER BY post_date DESC"); 
     50        $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts ORDER BY post_date DESC"); 
    5151        foreach ($arc_result as $arc_row) {          
    5252            $arc_year  = $arc_row->yyear; 
     
    126126if ( 1 == count($posts) ) { 
    127127 
    128     $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date"); 
     128    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id ORDER BY comment_date"); 
    129129    if ($comments) { 
    130130    ?>  
  • trunk/wp-admin/import-b2.php

    r1117 r1355  
    8383 
    8484while ($row = mysql_fetch_row($result)) { 
    85     if ($row[0] == $tablelinks) 
     85    if ($row[0] == $wpdb->links) 
    8686        $got_links = true; 
    87     if ($row[0] == $tablelinkcategories) 
     87    if ($row[0] == $wpdb->linkcategories) 
    8888        $got_cats = true; 
    8989    //print "Table: $row[0]<br />\n"; 
    9090} 
    9191if (!$got_cats) { 
    92     echo "<p>Can't find table '$tablelinkcategories', gonna create it...</p>\n"; 
    93     $sql = "CREATE TABLE $tablelinkcategories ( " . 
     92    echo "<p>Can't find table '$wpdb->linkcategories', gonna create it...</p>\n"; 
     93    $sql = "CREATE TABLE $wpdb->linkcategories ( " . 
    9494           " cat_id int(11) NOT NULL auto_increment, " . 
    9595           " cat_name tinytext NOT NULL, ". 
     
    9797           " PRIMARY KEY (cat_id) ". 
    9898           ") "; 
    99     $result = mysql_query($sql) or print ("Can't create the table '$tablelinkcategories' in the database.<br />" . $sql . "<br />" . mysql_error()); 
     99    $result = mysql_query($sql) or print ("Can't create the table '$wpdb->linkcategories' in the database.<br />" . $sql . "<br />" . mysql_error()); 
    100100    if ($result != false) { 
    101         echo "<p>Table '$tablelinkcategories' created OK</p>\n"; 
     101        echo "<p>Table '$wpdb->linkcategories' created OK</p>\n"; 
    102102        $got_cats = true; 
    103103    } 
    104104} else { 
    105     echo "<p>Found table '$tablelinkcategories', don't need to create it...</p>\n"; 
     105    echo "<p>Found table '$wpdb->linkcategories', don't need to create it...</p>\n"; 
    106106        $got_cats = true; 
    107107} 
    108108if (!$got_links) { 
    109     echo "<p>Can't find '$tablelinks', gonna create it...</p>\n"; 
    110     $sql = "CREATE TABLE $tablelinks ( " . 
     109    echo "<p>Can't find '$wpdb->links', gonna create it...</p>\n"; 
     110    $sql = "CREATE TABLE $wpdb->links ( " . 
    111111           " link_id int(11) NOT NULL auto_increment,           " . 
    112112           " link_url varchar(255) NOT NULL default '',         " . 
     
    124124           " PRIMARY KEY (link_id)                              " . 
    125125           ") "; 
    126     $result = mysql_query($sql) or print ("Can't create the table '$tablelinks' in the database.<br />" . $sql . "<br />" . mysql_error()); 
    127     $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');"); 
    128     $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');"); 
    129     $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://zed1.com/b2/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');"); 
     126    $result = mysql_query($sql) or print ("Can't create the table '$wpdb->links' in the database.<br />" . $sql . "<br />" . mysql_error()); 
     127    $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');"); 
     128    $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');"); 
     129    $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://zed1.com/b2/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');"); 
    130130 
    131131    if ($result != false) { 
    132         echo "<p>Table '$tablelinks' created OK</p>\n"; 
     132        echo "<p>Table '$wpdb->links' created OK</p>\n"; 
    133133        $got_links = true; 
    134134    } 
    135135} else { 
    136     echo "<p>Found table '$tablelinks', don't need to create it...</p>\n"; 
     136    echo "<p>Found table '$wpdb->links', don't need to create it...</p>\n"; 
    137137    echo "<p>... may need to update it though. Looking for column link_updated...</p>\n"; 
    138     $query = "SELECT link_updated FROM $tablelinks LIMIT 1"; 
     138    $query = "SELECT link_updated FROM $wpdb->links LIMIT 1"; 
    139139    $q = @mysql_query($query); 
    140140    if ($q != false) { 
     
    143143        } 
    144144    } else { 
    145         $query = "ALTER TABLE $tablelinks ADD COLUMN link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'"; 
     145        $query = "ALTER TABLE $wpdb->links ADD COLUMN link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'"; 
    146146        $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error()); 
    147147        echo "<p>Added column link_updated...</p>\n"; 
    148148    } 
    149149    echo "<p>Looking for column link_rel...</p>\n"; 
    150     $query = "SELECT link_rel FROM $tablelinks LIMIT 1"; 
     150    $query = "SELECT link_rel FROM $wpdb->links LIMIT 1"; 
    151151    $q = @mysql_query($query); 
    152152    if ($q != false) { 
     
    155155        } 
    156156    } else { 
    157         $query = "ALTER TABLE $tablelinks ADD COLUMN link_rel varchar(255) NOT NULL DEFAULT '' "; 
     157        $query = "ALTER TABLE $wpdb->links ADD COLUMN link_rel varchar(255) NOT NULL DEFAULT '' "; 
    158158        $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error()); 
    159159        echo "<p>Added column link_rel...</p>\n"; 
     
    164164if ($got_links && $got_cats) { 
    165165    echo "<p>Looking for category 1...</p>\n"; 
    166     $sql = "SELECT * FROM $tablelinkcategories WHERE cat_id=1 "; 
    167     $result = mysql_query($sql) or print ("Can't query '$tablelinkcategories'.<br />" . $sql . "<br />" . mysql_error()); 
     166    $sql = "SELECT * FROM $wpdb->linkcategories WHERE cat_id=1 "; 
     167    $result = mysql_query($sql) or print ("Can't query '$wpdb->linkcategories'.<br />" . $sql . "<br />" . mysql_error()); 
    168168    if ($result != false) { 
    169169        if ($row = mysql_fetch_object($result)) { 
     
    172172        } else { 
    173173            echo "<p>Gonna insert category 1...</p>\n"; 
    174             $sql = "INSERT INTO $tablelinkcategories (cat_id, cat_name) VALUES (1, 'General')"; 
     174            $sql = "INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, 'General')"; 
    175175            $result = mysql_query($sql) or print ("Can't query insert category.<br />" . $sql . "<br />" . mysql_error()); 
    176176            if ($result != false) { 
     
    197197<?php 
    198198 
    199 $query = "ALTER TABLE $tableposts ADD COLUMN post_excerpt text NOT NULL;"; 
     199$query = "ALTER TABLE $wpdb->posts ADD COLUMN post_excerpt text NOT NULL;"; 
    200200$q = $wpdb->query($query); 
    201201// 0.71 mods 
    202 $query = "ALTER TABLE $tableposts ADD post_status ENUM('publish','draft','private') NOT NULL, 
     202$query = "ALTER TABLE $wpdb->posts ADD post_status ENUM('publish','draft','private') NOT NULL, 
    203203ADD comment_status ENUM('open','closed') NOT NULL, 
    204204ADD ping_status ENUM('open','closed') NOT NULL, 
     
    210210 
    211211<?php 
    212 $query = "ALTER TABLE $tableposts DROP INDEX ID"; 
     212$query = "ALTER TABLE $wpdb->posts DROP INDEX ID"; 
    213213 
    214214$q = $wpdb->query($query); 
     
    218218<p>One down, two to go...</p> 
    219219 
    220 <?php 
    221  
    222 $query="ALTER TABLE $tablesettings DROP INDEX ID"; 
    223 $q = $wpdb->query($query); 
    224  
    225 ?> 
    226220 
    227221<p>So far so good.</p> 
    228222<?php 
    229223 
    230 $query="ALTER TABLE $tableposts DROP post_karma"; 
     224$query="ALTER TABLE $wpdb->posts DROP post_karma"; 
    231225$q = $wpdb->query($query); 
    232226flush(); 
     
    237231<?php 
    238232 
    239 $query = "ALTER TABLE $tableusers DROP INDEX ID"; 
     233$query = "ALTER TABLE $wpdb->users DROP INDEX ID"; 
    240234 
    241235$q = $wpdb->query($query); 
  • trunk/wp-admin/import-blogger.php

    r1285 r1355  
    6464            $post_author = trim(addslashes($postinfo[1])); 
    6565            // we'll check the author is registered already 
    66             $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE user_login = '$post_author'"); 
     66            $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$post_author'"); 
    6767            if (!$user) { // seems s/he's not, so let's register 
    6868                $user_ip = '127.0.0.1'; 
     
    7777                $user_joindate = addslashes($user_joindate); 
    7878                $result = $wpdb->query(" 
    79                 INSERT INTO $tableusers ( 
     79                INSERT INTO $wpdb->users ( 
    8080                    user_login, 
    8181                    user_pass, 
     
    106106            } 
    107107 
    108             $post_author_ID = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$post_author'"); 
     108            $post_author_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'"); 
    109109 
    110110            $post_date = explode(' ', $post_date); 
     
    129129             
    130130            // Quick-n-dirty check for dups: 
    131             $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $tableposts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A); 
     131            $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $wpdb->posts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A); 
    132132            if ($dupcheck[0]['ID']) { 
    133133                print "<br />\nSkipping duplicate post, ID = '" . $dupcheck[0]['ID'] . "'<br />\n"; 
     
    138138 
    139139            $result = $wpdb->query(" 
    140             INSERT INTO $tableposts  
     140            INSERT INTO $wpdb->posts  
    141141                (post_author,post_date,post_content,post_title,post_category) 
    142142            VALUES  
     
    152152    /* we've still got a bug that adds some empty posts with the date 0000-00-00 00:00:00 
    153153       here's the bugfix: */ 
    154     $result = $wpdb->query("DELETE FROM $tableposts WHERE post_date=\"0000-00-00 00:00:00\""); 
     154    $result = $wpdb->query("DELETE FROM $wpdb->posts WHERE post_date=\"0000-00-00 00:00:00\""); 
    155155 
    156156    upgrade_all(); 
  • trunk/wp-admin/import-greymatter.php

    r1190 r1355  
    8888        $user_joindate=addslashes($user_joindate); 
    8989 
    90         $loginthere = $wpdb->get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'"); 
     90        $loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'"); 
    9191        if ($loginthere) { 
    9292            echo "<li>user <i>$user_login</i>... <b>Already exists</b></li>"; 
     
    9494        } 
    9595 
    96         $query = "INSERT INTO $tableusers (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')"; 
     96        $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')"; 
    9797        $result = mysql_query($query); 
    9898        if ($result==false) { 
     
    140140            $post_author=trim(addslashes($postinfo[1])); 
    141141            // we'll check the author is registered, or if it's a deleted author 
    142             $sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'"; 
     142            $sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'"; 
    143143            $result = mysql_query($sql); 
    144144            if (!mysql_num_rows($result)) { // if deleted from GM, we register the author as a level 0 user in b2 
     
    153153                $user_url=addslashes(""); 
    154154                $user_joindate=addslashes($user_joindate); 
    155                 $query = "INSERT INTO $tableusers (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')"; 
     155                $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')"; 
    156156                $result = mysql_query($query); 
    157157                if ($result==false) { 
     
    161161            } 
    162162 
    163             $sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'"; 
     163            $sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'"; 
    164164            $result = mysql_query($sql); 
    165165            $myrow = mysql_fetch_array($result); 
     
    188188            $post_karma=$postinfo[12]; 
    189189 
    190             $query = "INSERT INTO $tableposts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')"; 
     190            $query = "INSERT INTO $wpdb->posts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')"; 
    191191            $result = mysql_query($query) or die(mysql_error()); 
    192192 
     
    194194                die ("Error in posting..."); 
    195195             
    196             $sql2 = "SELECT * FROM $tableposts WHERE 1=1 ORDER BY ID DESC LIMIT 1"; 
     196            $sql2 = "SELECT * FROM $wpdb->posts WHERE 1=1 ORDER BY ID DESC LIMIT 1"; 
    197197            $result2 = mysql_query($sql2); 
    198198            $myrow2 = mysql_fetch_array($result2); 
     
    200200 
    201201            // Grab a default category. 
    202             $post_category = $wpdb->get_var("SELECT cat_ID FROM $tablecategories LIMIT 1"); 
     202            $post_category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1"); 
    203203 
    204204            // Update the post2cat table. 
    205             $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category"); 
     205            $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); 
    206206               
    207207            if (!$exists) { 
    208208              $wpdb->query(" 
    209                     INSERT INTO $tablepost2cat 
     209                    INSERT INTO $wpdb->post2cat 
    210210                    (post_id, category_id) 
    211211                    VALUES 
     
    237237                    $comment_content=addslashes($commentinfo[12]); 
    238238 
    239                     $sql3 = "INSERT INTO $tablecomments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')"; 
     239                    $sql3 = "INSERT INTO $wpdb->comments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')"; 
    240240                    $result3 = mysql_query($sql3); 
    241241                    if (!$result3) 
  • trunk/wp-admin/import-livejournal.php

    r1147 r1355  
    9595 
    9696// Now lets put it in the DB 
    97 if ($wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'")) : 
     97if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'")) : 
    9898    echo 'Post already imported'; 
    9999else :  
    100100     
    101     $wpdb->query("INSERT INTO $tableposts  
     101    $wpdb->query("INSERT INTO $wpdb->posts  
    102102        (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name) 
    103103        VALUES  
    104104        ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comment_status', '$ping_status', '$post_name')"); 
    105     $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'"); 
     105    $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'"); 
    106106    if (!$post_id) die("couldn't get post ID"); 
    107     $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = 1"); 
    108     if (!$exists) $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, 1) "); 
     107    $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1"); 
     108    if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) "); 
    109109    echo 'Done!</li>'; 
    110110endif; 
  • trunk/wp-admin/import-mt.php

    r1292 r1355  
    7272 
    7373function users_form($n) { 
    74     global $wpdb, $tableusers, $testing; 
    75     $users = $wpdb->get_results("SELECT * FROM $tableusers ORDER BY ID"); 
     74    global $wpdb, $testing; 
     75    $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID"); 
    7676    ?><select name="userselect[<?php echo $n; ?>]"> 
    7777    <option value="#NONE#">- Select -</option> 
     
    148148    //function to check the authorname and do the mapping 
    149149    function checkauthor($author) { 
    150     global $wpdb, $tableusers, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file 
     150    global $wpdb, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file 
    151151    $md5pass = md5(changeme); 
    152152    if (!(in_array($author, $mtnames))) { //a new mt author name is found 
    153153        ++$j; 
    154154        $mtnames[$j] = $author; //add that new mt author name to an array  
    155         $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user 
     155        $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user 
    156156        if (!$user_id) { //banging my head against the desk now.  
    157157            if ($newauthornames[$j] == 'left_blank') { //check if the user does not want to change the authorname 
    158                 $wpdb->query("INSERT INTO $tableusers (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author 
    159                 $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$author'"); 
     158                $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author 
     159                $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$author'"); 
    160160                $newauthornames[$j] = $author; //now we have a name, in the place of left_blank. 
    161161            } else { 
    162             $wpdb->query("INSERT INTO $tableusers (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name 
    163             $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$newauthornames[$j]'"); 
     162            $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name 
     163            $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'"); 
    164164            } 
    165165        } else return $user_id; // return pre-existing wp username if it exists 
    166166    } else { 
    167167    $key = array_search($author, $mtnames); //find the array key for $author in the $mtnames array 
    168     $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames 
     168    $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames 
    169169    } 
    170170    return $user_id; 
     
    273273 
    274274    // Let's check to see if it's in already 
    275     if ($wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$post_title' AND post_date = '$post_date'")) { 
     275    if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'")) { 
    276276        echo "Post already imported."; 
    277277    } else { 
    278278        $post_author = checkauthor($post_author);//just so that if a post already exists, new users are not created by checkauthor 
    279         $wpdb->query("INSERT INTO $tableposts ( 
     279        $wpdb->query("INSERT INTO $wpdb->posts ( 
    280280            post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt) 
    281281            VALUES  
    282282            ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_name','$post_date', '$post_date_gmt')"); 
    283         $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$post_title' AND post_date = '$post_date'"); 
     283        $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'"); 
    284284        if (0 != count($post_categories)) { 
    285285            foreach ($post_categories as $post_category) { 
    286286            // See if the category exists yet 
    287             $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'"); 
     287            $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'"); 
    288288            if (!$cat_id && '' != trim($post_category)) { 
    289289                $cat_nicename = sanitize_title($post_category); 
    290                 $wpdb->query("INSERT INTO $tablecategories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')"); 
    291                 $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'"); 
     290                $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')"); 
     291                $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'"); 
    292292            } 
    293293            if ('' == trim($post_category)) $cat_id = 1; 
    294294            // Double check it's not there already 
    295             $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = $cat_id"); 
     295            $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id"); 
    296296 
    297297             if (!$exists) {  
    298298                $wpdb->query(" 
    299                 INSERT INTO $tablepost2cat 
     299                INSERT INTO $wpdb->post2cat 
    300300                (post_id, category_id) 
    301301                VALUES 
     
    305305        } // end category loop 
    306306        } else { 
    307             $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = 1"); 
    308             if (!$exists) $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, 1) "); 
     307            $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1"); 
     308            if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) "); 
    309309        } 
    310310        echo " Post imported successfully..."; 
     
    339339 
    340340            // Check if it's already there 
    341             if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 
    342                 $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) 
     341            if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 
     342                $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) 
    343343                VALUES 
    344344                ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')"); 
     
    384384       
    385385            // Check if it's already there 
    386             if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 
    387                 $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) 
     386            if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { 
     387                $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) 
    388388                VALUES 
    389389                ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')"); 
  • trunk/wp-admin/import-rss.php

    r1264 r1355  
    125125// So we do it as a last resort 
    126126if ('' == $title) :  
    127     $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_content = '$content' AND post_date = '$post_date'"); 
     127    $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' AND post_date = '$post_date'"); 
    128128else : 
    129     $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'"); 
     129    $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'"); 
    130130endif; 
    131131 
     
    135135else :  
    136136     
    137     $wpdb->query("INSERT INTO $tableposts  
     137    $wpdb->query("INSERT INTO $wpdb->posts  
    138138        (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name) 
    139139        VALUES  
    140140        ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comme