home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / upgrade / upd-2.0.17-to-2.0.18 / index.php
Encoding:
PHP Script  |  2007-12-16  |  1.4 KB  |  59 lines

  1. <?php
  2.  
  3. class upgrade_2018 {
  4.  
  5.     var $usedFiles = array( );
  6.  
  7.     function isApplied() {
  8.         return $this->check_config_type();
  9.     }
  10.  
  11.     function apply() {
  12.         return $this->apply_alter_tables();
  13.     }
  14.  
  15.     function check_config_type() {
  16.         $db = $GLOBALS['xoopsDB'];
  17.         $sql = "SHOW COLUMNS FROM " . $db->prefix("config") . " LIKE 'conf_title'";
  18.         $result = $db->queryF( $sql );
  19.         while ($row = $db->fetchArray($result)) {
  20.             if (strtolower( trim($row["Type"]) ) == "varchar(255)") {
  21.                 return true;
  22.             }
  23.         }
  24.         return false;
  25.     }
  26.  
  27.     function query( $sql ) {
  28.         echo $sql . "<br />";
  29.         $db = $GLOBALS['xoopsDB'];
  30.         if ( ! ( $ret = $db->queryF( $sql ) ) ) {
  31.             echo $db->error();
  32.         }
  33.     }
  34.  
  35.     function apply_alter_tables() {
  36.         $db = $GLOBALS['xoopsDB'];
  37.         $this->fields = array(
  38.                         "config" => array(
  39.                                         "conf_title" => "varchar(255) NOT NULL default ''",
  40.                                         "conf_desc"  => "varchar(255) NOT NULL default ''" 
  41.                                         ),
  42.                         "configcategory" => array( "confcat_name"  => "varchar(255) NOT NULL default ''" ),
  43.                         );
  44.  
  45.         foreach( $this->fields as $table => $data ) {
  46.             foreach ($data as $field => $property) {
  47.                 $sql = "ALTER TABLE " . $db->prefix($table) . " CHANGE `$field` `$field` $property";
  48.                 $this->query( $sql );
  49.             }
  50.         }
  51.         return true;
  52.     }
  53. }
  54.  
  55. $upg = new upgrade_2018();
  56. return $upg;
  57.  
  58. ?>
  59.