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-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);
Note: See TracChangeset for help on using the changeset viewer.