Changeset 265 for trunk/wp-admin/wp-install-helper.php
- Timestamp:
- 07/23/2003 12:26:03 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/wp-install-helper.php
r236 r265 74 74 return true; 75 75 } 76 77 78 /** 79 ** check_column() 80 ** Check column matches passed in criteria. 81 ** Pass in null to skip checking that criteria 82 ** Returns: true if it matches 83 ** false otherwise 84 ** (case sensitive) Column names returned from DESC table are: 85 ** Field 86 ** Type 87 ** Null 88 ** Key 89 ** Default 90 ** Extra 91 */ 92 function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) { 93 global $wpdb; 94 $diffs = 0; 95 $results = $wpdb->get_results("DESC $table_name"); 96 97 foreach ($results as $row ) { 98 print_r($row); 99 if ($row->Field == $col_name) { 100 // got our column, check the params 101 echo ("checking $row->Type != $col_type\n"); 102 if (($col_type != null) && ($row->Type != $col_type)) { 103 ++$diffs; 104 } 105 if (($is_null != null) && ($row->Null != $is_null)) { 106 ++$diffs; 107 } 108 if (($key != null) && ($row->Key != $key)) { 109 ++$diffs; 110 } 111 if (($default != null) && ($row->Default != $default)) { 112 ++$diffs; 113 } 114 if (($extra != null) && ($row->Extra != $extra)) { 115 ++$diffs; 116 } 117 if ($diffs > 0) 118 return false; 119 return true; 120 } // end if found our column 121 } 122 return false; 123 } 124 125 /* 126 echo "<p>testing</p>"; 127 echo "<pre>"; 128 129 //check_column('wp_links', 'link_description', 'mediumtext'); 130 //if (check_column($tablecomments, 'comment_author', 'tinytext')) 131 // echo "ok\n"; 132 $error_count = 0; 133 $tablename = $tablelinks; 134 // check the column 135 if (!check_column($tablelinks, 'link_description', 'varchar(255)')) 136 { 137 $ddl = "ALTER TABLE $tablelinks MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; 138 $q = $wpdb->query($ddl); 139 } 140 if (check_column($tablelinks, 'link_description', 'varchar(255)')) { 141 $res .= $tablename . ' - ok <br />'; 142 } else { 143 $res .= 'There was a problem with ' . $tablename . '<br />'; 144 ++$error_count; 145 } 146 echo "</pre>"; 147 */ 76 148 ?>
Note: See TracChangeset
for help on using the changeset viewer.