diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-11-24 16:16:44 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-11-24 16:16:44 +0000 |
commit | 600b71019494e1c29898a620e58c0d2602f37b74 (patch) | |
tree | 21181d77ad4ebbcd42cd883e509c08a568d29514 /wp-admin/install-helper.php | |
parent | 7935d0bd9ef23d32ae29a95bd6c3ea0b6eab2973 (diff) | |
download | wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.gz wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.xz wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.zip |
WP Merge to 4524
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@810 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/install-helper.php')
-rw-r--r-- | wp-admin/install-helper.php | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php index 86138db..b441c34 100644 --- a/wp-admin/install-helper.php +++ b/wp-admin/install-helper.php @@ -9,21 +9,21 @@ $debug = 0; ** false on error */ function maybe_create_table($table_name, $create_ddl) { - global $wpdb; - foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { - if ($table == $table_name) { - return true; - } - } - //didn't find it try to create it. - $q = $wpdb->query($create_ddl); - // we cannot directly tell that whether this succeeded! - foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { - if ($table == $table_name) { - return true; - } - } - return false; + global $wpdb; + foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { + if ($table == $table_name) { + return true; + } + } + //didn't find it try to create it. + $q = $wpdb->query($create_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { + if ($table == $table_name) { + return true; + } + } + return false; } /** @@ -33,22 +33,22 @@ function maybe_create_table($table_name, $create_ddl) { ** false on error */ function maybe_add_column($table_name, $column_name, $create_ddl) { - global $wpdb, $debug; - foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { - if ($debug) echo("checking $column == $column_name<br />"); - if ($column == $column_name) { - return true; - } - } - //didn't find it try to create it. - $q = $wpdb->query($create_ddl); - // we cannot directly tell that whether this succeeded! - foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { - if ($column == $column_name) { - return true; - } - } - return false; + global $wpdb, $debug; + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($debug) echo("checking $column == $column_name<br />"); + if ($column == $column_name) { + return true; + } + } + //didn't find it try to create it. + $q = $wpdb->query($create_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($column == $column_name) { + return true; + } + } + return false; } @@ -59,21 +59,21 @@ function maybe_add_column($table_name, $column_name, $create_ddl) { ** false on error */ function maybe_drop_column($table_name, $column_name, $drop_ddl) { - global $wpdb; - foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { - if ($column == $column_name) { - //found it try to drop it. - $q = $wpdb->query($drop_ddl); - // we cannot directly tell that whether this succeeded! - foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { - if ($column == $column_name) { - return false; - } - } - } - } - // else didn't find it - return true; + global $wpdb; + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($column == $column_name) { + //found it try to drop it. + $q = $wpdb->query($drop_ddl); + // we cannot directly tell that whether this succeeded! + foreach ($wpdb->get_col("DESC $table_name",0) as $column ) { + if ($column == $column_name) { + return false; + } + } + } + } + // else didn't find it + return true; } @@ -92,45 +92,45 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) { ** Extra */ function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) { - global $wpdb, $debug; - $diffs = 0; - $results = $wpdb->get_results("DESC $table_name"); - - foreach ($results as $row ) { - if ($debug > 1) print_r($row); - if ($row->Field == $col_name) { - // got our column, check the params - if ($debug) echo ("checking $row->Type against $col_type\n"); - if (($col_type != null) && ($row->Type != $col_type)) { - ++$diffs; - } - if (($is_null != null) && ($row->Null != $is_null)) { - ++$diffs; - } - if (($key != null) && ($row->Key != $key)) { - ++$diffs; - } - if (($default != null) && ($row->Default != $default)) { - ++$diffs; - } - if (($extra != null) && ($row->Extra != $extra)) { - ++$diffs; - } - if ($diffs > 0) { - if ($debug) echo ("diffs = $diffs returning false\n"); - return false; - } - return true; - } // end if found our column - } - return false; + global $wpdb, $debug; + $diffs = 0; + $results = $wpdb->get_results("DESC $table_name"); + + foreach ($results as $row ) { + if ($debug > 1) print_r($row); + if ($row->Field == $col_name) { + // got our column, check the params + if ($debug) echo ("checking $row->Type against $col_type\n"); + if (($col_type != null) && ($row->Type != $col_type)) { + ++$diffs; + } + if (($is_null != null) && ($row->Null != $is_null)) { + ++$diffs; + } + if (($key != null) && ($row->Key != $key)) { + ++$diffs; + } + if (($default != null) && ($row->Default != $default)) { + ++$diffs; + } + if (($extra != null) && ($row->Extra != $extra)) { + ++$diffs; + } + if ($diffs > 0) { + if ($debug) echo ("diffs = $diffs returning false\n"); + return false; + } + return true; + } // end if found our column + } + return false; } - + /* echo "<p>testing</p>"; echo "<pre>"; -//check_column('wp_links', 'link_description', 'mediumtext'); +//check_column('wp_links', 'link_description', 'mediumtext'); //if (check_column($wpdb->comments, 'comment_author', 'tinytext')) // echo "ok\n"; $error_count = 0; @@ -138,15 +138,15 @@ $tablename = $wpdb->links; // check the column if (!check_column($wpdb->links, 'link_description', 'varchar(255)')) { - $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; - $q = $wpdb->query($ddl); + $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; + $q = $wpdb->query($ddl); } if (check_column($wpdb->links, 'link_description', 'varchar(255)')) { - $res .= $tablename . ' - ok <br />'; + $res .= $tablename . ' - ok <br />'; } else { - $res .= 'There was a problem with ' . $tablename . '<br />'; - ++$error_count; + $res .= 'There was a problem with ' . $tablename . '<br />'; + ++$error_count; } echo "</pre>"; */ -?>
\ No newline at end of file +?> |