shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

1007.php (8962B)


      1 <?php
      2 class ModelUpgrade1007 extends Model {
      3 	public function upgrade() {
      4 		// Download
      5 		$this->db->query("ALTER TABLE `" . DB_PREFIX . "download` CHANGE `filename` `filename` varchar(140) NOT NULL");
      6 
      7 		// Download
      8 		$this->db->query("ALTER TABLE `" . DB_PREFIX . "modification` CHANGE `xml` `xml` mediumtext NOT NULL");
      9 		
     10 		// Extension
     11 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension` WHERE `type` = 'theme'");
     12 		
     13 		if (!$query->num_rows) {
     14 			$this->db->query("INSERT INTO `" . DB_PREFIX . "extension` SET `type` = 'theme', `code` = 'theme_default'");
     15 			
     16 			// Setting
     17 			$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_directory', `value` = 'default'");
     18 			$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_status', `value` = '1'");		
     19 		}
     20 				
     21 		// Setting
     22 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_product_limit' WHERE `code` = 'config' AND `key` = 'config_product_limit'");
     23 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_product_description_length' WHERE `code` = 'config' AND `key` = 'config_product_description_length'");
     24 		
     25 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_location_width' WHERE `code` = 'config' AND `key` = 'config_image_location_width'");
     26 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_location_height' WHERE `code` = 'config' AND `key` = 'config_image_location_height'");
     27 		
     28 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_cart_width' WHERE `code` = 'config' AND `key` = 'config_image_cart_width'");
     29 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_cart_height' WHERE `code` = 'config' AND `key` = 'config_image_cart_height'");
     30 		
     31 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_wishlist_width' WHERE `code` = 'config' AND `key` = 'config_image_wishlist_width'");
     32 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_wishlist_height' WHERE `code` = 'config' AND `key` = 'config_image_wishlist_height'");
     33 		
     34 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_category_width' WHERE `code` = 'config' AND `key` = 'config_image_category_width'");
     35 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_category_height' WHERE `code` = 'config' AND `key` = 'config_image_category_height'");
     36 		
     37 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_thumb_width' WHERE `code` = 'config' AND `key` = 'config_image_thumb_width'");
     38 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_thumb_height' WHERE `code` = 'config' AND `key` = 'config_image_thumb_height'");
     39 		
     40 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_popup_width' WHERE `code` = 'config' AND `key` = 'config_image_popup_width'");
     41 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_popup_height' WHERE `code` = 'config' AND `key` = 'config_image_popup_height'");
     42 		
     43 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_product_width' WHERE `code` = 'config' AND `key` = 'config_image_product_width'");
     44 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_product_height' WHERE `code` = 'config' AND `key` = 'config_image_product_height'");
     45 		
     46 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_additional_width' WHERE `code` = 'config' AND `key` = 'config_image_additional_width'");
     47 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_additional_height' WHERE `code` = 'config' AND `key` = 'config_image_additional_height'");
     48 		
     49 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_related_width' WHERE `code` = 'config' AND `key` = 'config_image_related_width'");
     50 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_related_height' WHERE `code` = 'config' AND `key` = 'config_image_related_height'");
     51 		
     52 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_compare_width' WHERE `code` = 'config' AND `key` = 'config_image_compare_width'");
     53 		$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `code` = 'theme_default', `key` = 'theme_default_image_compare_height' WHERE `code` = 'config' AND `key` = 'config_image_compare_height'");
     54 			
     55 		// Paypal Express
     56 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "paypal_order' AND COLUMN_NAME = 'created'");
     57 
     58 		if ($query->num_rows) {
     59 			$this->db->query("ALTER TABLE `" . DB_PREFIX . "paypal_order` CHANGE `created` `date_added` datetime NOT NULL");
     60 		}
     61 
     62 		// Paypal Express
     63 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "paypal_order' AND COLUMN_NAME = 'modified'");
     64 
     65 		if ($query->num_rows) {
     66 			$this->db->query("ALTER TABLE `" . DB_PREFIX . "paypal_order` CHANGE `modified` `date_modified` datetime NOT NULL");
     67 		}
     68 
     69 		// Paypal Express
     70 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "paypal_order_transaction' AND COLUMN_NAME = 'parent_transaction_id'");
     71 
     72 		if ($query->num_rows) {
     73 			$this->db->query("ALTER TABLE `" . DB_PREFIX . "paypal_order_transaction` CHANGE `parent_transaction_id` `parent_id` CHAR(20) NOT NULL");
     74 		}
     75 
     76 		// Paypal Express
     77 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "paypal_order_transaction' AND COLUMN_NAME = 'created'");
     78 
     79 		if ($query->num_rows) {
     80 			$this->db->query("ALTER TABLE `" . DB_PREFIX . "paypal_order_transaction` CHANGE `created` `date_added` datetime NOT NULL");
     81 		}
     82 		
     83 		// Banner	
     84 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "banner_image' AND COLUMN_NAME = 'language_id'");
     85 		
     86 		if (!$query->num_rows) {
     87 			$this->db->query("ALTER TABLE `" . DB_PREFIX . "banner_image` ADD `language_id` INT(11) NOT NULL AFTER `banner_id`");
     88 		}
     89 
     90 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "banner_image' AND COLUMN_NAME = 'title'");
     91 		
     92 		if (!$query->num_rows) {
     93 			$this->db->query("ALTER TABLE `" . DB_PREFIX . "banner_image` ADD `title` VARCHAR(64) NOT NULL AFTER `language_id`");
     94 		}
     95 					
     96 		$query = $this->db->query("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = '" . DB_PREFIX . "banner_image_description'");
     97 
     98 		if ($query->num_rows) {
     99 			$banner_image_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "banner_image`");
    100 
    101 			foreach ($banner_image_query->rows as $banner_image) {
    102 				$this->db->query("DELETE FROM `" . DB_PREFIX . "banner_image` WHERE banner_image_id = '" . (int)$banner_image['banner_image_id'] . "'");
    103 				
    104 				$banner_image_description_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "banner_image_description` WHERE banner_image_id = '" . (int)$banner_image['banner_image_id'] . "'");
    105 				
    106 				foreach ($banner_image_description_query->rows as $banner_image_description) {
    107 					$this->db->query("INSERT INTO `" . DB_PREFIX . "banner_image` SET banner_id = '" . (int)$banner_image['banner_id'] . "', language_id = '" . (int)$banner_image_description['language_id'] . "', title = '" . $this->db->escape($banner_image_description['title']) . "', link = '" . $this->db->escape($banner_image['link']) . "', image = '" . $this->db->escape($banner_image['image']) . "', sort_order = '" . (int)$banner_image['sort_order'] . "'");
    108 				}
    109 			}
    110 			
    111 			$this->db->query("DROP TABLE `" . DB_PREFIX . "banner_image_description`");
    112 		}
    113 	}
    114 }