Changeset 922
- Timestamp:
- 10/02/05 10:44:37 (3 years ago)
- Files:
-
- 1 modified
-
trunk/rss/schema.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rss/schema.php
r878 r922 87 87 } 88 88 89 function rss_query_wrapper($query, $dieOnError=true, $preventRecursion=false) { 90 if (defined('DUMP_SCHEMA')) { 91 echo $query . ";\n"; 92 } else { 93 rss_query($query,$dieOnError,$preventRecursion); 94 } 95 } 89 96 90 97 /** … … 145 152 function _init_channels() { 146 153 $table = getTable('channels'); 147 rss_query ('DROP TABLE IF EXISTS ' . $table, true, true);154 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 148 155 $sql_create = str_replace('__table__',$table, <<< _SQL_ 149 156 CREATE TABLE __table__ ( … … 163 170 ); 164 171 165 rss_query ($sql_create, false, true);172 rss_query_wrapper($sql_create, false, true); 166 173 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 167 174 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); … … 176 183 function _init_folders() { 177 184 $table = getTable('folders'); 178 rss_query ('DROP TABLE IF EXISTS ' . $table, true, true);185 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 179 186 $sql_create = str_replace('__table__',$table, <<< _SQL_ 180 187 CREATE TABLE __table__ ( … … 188 195 ); 189 196 190 rss_query ($sql_create, false, true);191 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 192 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); 193 return 0; 194 } 195 196 197 rss_query ("INSERT INTO $table (id,name) VALUES (0,'')", false, true);197 rss_query_wrapper($sql_create, false, true); 198 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 199 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); 200 return 0; 201 } 202 203 204 rss_query_wrapper ("INSERT INTO $table (id,name) VALUES (0,'')", false, true); 198 205 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 199 206 rss_error('The ' . $table . ' table was created successfully, but I couldn\'t insert the default values. Please do so manually!', RSS_ERROR_ERROR); 200 207 return 0; 201 208 } 202 rss_query ("update $table set id=0 where id=1", false, true);209 rss_query_wrapper ("update $table set id=0 where id=1", false, true); 203 210 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 204 211 rss_error('The ' . $table . ' table was created successfully, but I couldn\'t insert the default values. Please do so manually!', RSS_ERROR_ERROR); … … 215 222 $cfg_table = getTable('config'); 216 223 217 rss_query ('DROP TABLE IF EXISTS ' . $cfg_table, true, true);224 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $cfg_table, true, true); 218 225 219 226 $sql_create = str_replace('__config__',$cfg_table, <<< _SQL_ … … 230 237 ); 231 238 232 rss_query ($sql_create, false, true);239 rss_query_wrapper($sql_create, false, true); 233 240 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 234 241 rss_error('The ' .getTable('config') . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); … … 287 294 $ds=rss_real_escape_string($ds); 288 295 $e=rss_real_escape_string($e); 289 rss_query ('insert into '. getTable('config')296 rss_query_wrapper('insert into '. getTable('config') 290 297 . "(key_,value_,default_,type_,desc_,export_) VALUES (" 291 298 . "'$k','$v','$d','$t','$ds'," .($e?"'$e'":"null") .")",false,true); … … 303 310 function _init_item() { 304 311 $table = getTable('item'); 305 rss_query ('DROP TABLE IF EXISTS ' . $table, true, true);312 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 306 313 $sql_create = str_replace('__table__',$table, <<< _SQL_ 307 314 CREATE TABLE __table__ ( … … 322 329 ); 323 330 324 rss_query ($sql_create, false, true);331 rss_query_wrapper($sql_create, false, true); 325 332 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 326 333 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); … … 335 342 function _init_tag() { 336 343 $table = getTable('tag'); 337 rss_query ('DROP TABLE IF EXISTS ' . $table, true, true);344 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 338 345 $sql_create = str_replace('__table__',$table, <<< _SQL_ 339 346 CREATE TABLE __table__ ( … … 347 354 ); 348 355 349 rss_query ($sql_create, false, true);356 rss_query_wrapper($sql_create, false, true); 350 357 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 351 358 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); … … 361 368 function _init_metatag() { 362 369 $table = getTable('metatag'); 363 rss_query ('DROP TABLE IF EXISTS ' . $table, true, true);370 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 364 371 $sql_create = str_replace('__table__',$table, <<< _SQL_ 365 372 CREATE TABLE __table__ ( … … 374 381 ); 375 382 376 rss_query ($sql_create, false, true);383 rss_query_wrapper($sql_create, false, true); 377 384 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 378 385 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); … … 387 394 function _init_rating() { 388 395 $table = getTable('rating'); 389 rss_query ('DROP TABLE IF EXISTS ' . $table, true, true);396 rss_query_wrapper ('DROP TABLE IF EXISTS ' . $table, true, true); 390 397 $sql_create = str_replace('__table__',$table, <<< _SQL_ 391 398 CREATE TABLE __table__ ( … … 396 403 ); 397 404 398 rss_query ($sql_create, false, true);405 rss_query_wrapper($sql_create, false, true); 399 406 if (!rss_is_sql_error(RSS_SQL_ERROR_NO_ERROR)) { 400 407 rss_error('The ' . $table . 'table doesn\'t exist and I couldn\'t create it! Please create it manually.', RSS_ERROR_ERROR); … … 406 413 407 414 408 415 if (isset($argv) && in_array('--dump',$argv)) { 416 foreach ($argv as $idx => $arg) { 417 if (substr($arg,0,9) == '--prefix=') { 418 define ('DB_TABLE_PREFIX',substr($arg,9)); 419 } 420 } 421 require_once('init.php'); 422 define ('DUMP_SCHEMA', true); 423 424 foreach (array("channels","config","folders","item","metatag","tag","rating") as $tbl) { 425 call_user_func("_init_$tbl"); 426 } 427 428 429 } 409 430 410 431 ?>
