当前位置: 首页>>代码示例>>PHP>>正文


PHP UpdateUtil::table_exist方法代码示例

本文整理汇总了PHP中Cx\Lib\UpdateUtil::table_exist方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdateUtil::table_exist方法的具体用法?PHP UpdateUtil::table_exist怎么用?PHP UpdateUtil::table_exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cx\Lib\UpdateUtil的用法示例。


在下文中一共展示了UpdateUtil::table_exist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates old Currency names to the Text class,
  * and inserts default Currencyes if necessary
  * @return  boolean     false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     global $objDatabase;
     // Currency
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_currencies';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'symbol' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'increment' => array('type' => 'DECIMAL(6,5)', 'unsigned' => true, 'notnull' => true, 'default' => '0.01'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status'), 'default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'is_default'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
             // Migrate all Currency names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `id`, `code`, `name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Currency names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['id'];
                 $name = $objResult->fields['name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Currency name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
         return false;
     }
     // If the table did not exist, insert defaults
     $arrCurrencies = array('Schweizer Franken' => array('CHF', 'sFr.', 1.0, '0.05', 1, 1, 1), 'Euro' => array('EUR', html_entity_decode("€"), 1.18, '0.01', 2, 1, 0), 'United States Dollars' => array('USD', '$', 0.88, '0.01', 3, 1, 0));
     // There is no previous version of this table!
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure);
     // And there aren't even records to migrate, so
     foreach ($arrCurrencies as $name => $arrCurrency) {
         $query = "\n                INSERT INTO `contrexx_module_shop_currencies` (\n                    `code`, `symbol`, `rate`, `increment`,\n                    `ord`, `active`, `default`\n                ) VALUES (\n                    '" . join("','", $arrCurrency) . "'\n                )";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to insert default Currencies");
         }
         $id = $objDatabase->Insert_ID();
         if (!\Text::replace($id, FRONTEND_LANG_ID, 'Shop', self::TEXT_NAME, $name)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to add Text for default Currency name '{$name}'");
         }
     }
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:57,代码来源:Currency.class.php

示例2: errorHandler

 /**
  * Tries to fix any database problems
  * @return  boolean           False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     //die("Discount::errorHandler(): Disabled!<br />");
     // Discount
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_article_group';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     //\DBG::activate(DBG_DB);
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_ARTICLE);
         $query = "\n                SELECT `id`, `name`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query article group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_ARTICLE, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate article group names");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_customer_group';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_CUSTOMER);
         $query = "\n                SELECT `id`, `name`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query customer group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_CUSTOMER, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate customer group names");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_rel_discount_group';
     $table_structure = array('customer_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'article_group_id' => array('type' => 'int(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'rate' => array('type' => 'decimal(9,2)', 'notnull' => true, 'default' => '0.00'));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_discountgroup_count_name';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true));
     $table_index = array();
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         \Text::deleteByKey('Shop', self::TEXT_NAME_GROUP_COUNT);
         \Text::deleteByKey('Shop', self::TEXT_UNIT_GROUP_COUNT);
         $query = "\n                SELECT `id`, `name`, `unit`\n                  FROM `{$table_name}`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to query count group names", $query);
         }
         while (!$objResult->EOF) {
             $group_id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             $unit = $objResult->fields['unit'];
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_NAME_GROUP_COUNT, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group names");
             }
             if (!\Text::replace($group_id, $default_lang_id, 'Shop', self::TEXT_UNIT_GROUP_COUNT, $unit)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate count group units");
             }
             $objResult->MoveNext();
         }
         \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     }
     $table_name = DBPREFIX . 'module_shop_discountgroup_count_rate';
     $table_structure = array('group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'primary' => true), 'count' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 1, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:99,代码来源:Discount.class.php

示例3: errorHandler

 /**
  * Handles all kinds of database errors
  *
  * Creates the processors' table, and creates default entries if necessary
  * @return  boolean                         False. Always.
  * @global  ADOConnection   $objDatabase
  */
 static function errorHandler()
 {
     // PaymentProcessing
     $table_name_old = DBPREFIX . 'module_shop_processors';
     $table_name_new = DBPREFIX . 'module_shop_payment_processors';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new);
     }
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM("internal", "external")', 'default' => 'internal'), 'name' => array('type' => 'VARCHAR(255)', 'default' => ''), 'description' => array('type' => 'TEXT', 'default' => ''), 'company_url' => array('type' => 'VARCHAR(255)', 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => 1), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''));
     \Cx\Lib\UpdateUtil::table($table_name_new, $table_structure);
     $arrPsp = array(array(1, 'external', 'saferpay', 'Saferpay is a comprehensive Internet payment platform, specially developed for commercial applications. It provides a guarantee of secure payment processes over the Internet for merchants as well as for cardholders. Merchants benefit from the easy integration of the payment method into their e-commerce platform, and from the modularity with which they can take account of current and future requirements. Cardholders benefit from the security of buying from any shop that uses Saferpay.', 'http://www.saferpay.com/', 1, 'logo_saferpay.gif'), array(2, 'external', 'paypal', 'With more than 40 million member accounts in over 45 countries worldwide, PayPal is the world\'s largest online payment service. PayPal makes sending money as easy as sending email! Any PayPal member can instantly and securely send money to anyone in the U.S. with an email address. PayPal can also be used on a web-enabled cell phone. In the future, PayPal will be available to use on web-enabled pagers and other handheld devices.', 'http://www.paypal.com/', 1, 'logo_paypal.gif'), array(3, 'external', 'yellowpay', 'PostFinance vereinfacht das Inkasso im Online-Shop.', 'http://www.postfinance.ch/', 1, 'logo_postfinance.gif'), array(4, 'internal', 'internal', 'Internal no forms', '', 1, ''), array(9, 'internal', 'internal_lsv', 'LSV with internal form', '', 1, ''), array(10, 'external', 'datatrans', 'Die professionelle und komplette Payment-Lösung', 'http://datatrans.biz/', 1, 'logo_datatrans.gif'), array(11, 'external', 'mobilesolutions', 'PostFinance Mobile', 'https://postfinance.mobilesolutions.ch/', 1, 'logo_postfinance_mobile.gif'));
     $query_template = "\n            REPLACE INTO `{$table_name_new}` (\n                `id`, `type`, `name`,\n                `description`,\n                `company_url`, `status`, `picture`\n            ) VALUES (\n                ?, ?, ?, ?, ?, ?, ?\n            )";
     foreach ($arrPsp as $psp) {
         \Cx\Lib\UpdateUtil::sql($query_template, $psp);
     }
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     }
     // Drop obsolete PSPs -- see Payment::errorHandler()
     \Cx\Lib\UpdateUtil::sql("\n            DELETE FROM `" . DBPREFIX . "module_shop_payment_processors`\n             WHERE `id` IN (5, 6, 7, 8)");
     // Always
     return false;
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:30,代码来源:PaymentProcessing.class.php

示例4: errorHandler

    /**
     * Migrates existing old Shop mailtemplates to the new MailTemplate class
     * @return  boolean         False.  Always.
     * @throws  Cx\Lib\Update_DatabaseException
     */
    static function errorHandler()
    {
        // Mail
        \Cx\Core\MailTemplate\Controller\MailTemplate::errorHandler();
        if (\Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'core_mail_template')) {
            // Make sure there are no bodies lying around
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_NAME);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_FROM);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SENDER);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_REPLY);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_TO);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_CC);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_BCC);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SUBJECT);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE_HTML);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_ATTACHMENTS);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_INLINE);
        }
        $arrFrom = $arrSender = $arrSubject = array();
        $arrLanguageId = \FWLanguage::getIdArray();
        if (empty($arrLanguageId)) {
            throw new \Cx\Lib\Update_DatabaseException("Failed to get frontend language IDs");
        }
        if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_shop_mail')) {
            // Migrate existing templates from the shop to the MailTemplate,
            // appending "_backup_by_update" to the respective keys.
            // Make them unprotected.
            // These are the keys replacing the IDs:
            $arrKey = array(1 => 'order_confirmation', 2 => 'order_complete', 3 => 'customer_login', 4 => 'order_confirmation_login');
            foreach ($arrLanguageId as $lang_id) {
                // Mind that the template name is single language yet!
                $arrTemplates = self::getTemplateArray($lang_id);
                if (empty($arrTemplates)) {
                    continue;
                }
                foreach ($arrTemplates as $id => $arrTemplate) {
                    // NOTE: utf8_encode() may be necessary in some cases.
                    // It usually works without it, but was necessary on a few installations.
                    //                    $arrTemplate = array_map("utf8_encode", $arrTemplate);
                    if (!empty($arrTemplate['from']) && empty($arrFrom[$id])) {
                        $arrFrom[$id] = $arrTemplate['from'];
                    }
                    if (!empty($arrTemplate['sender']) && empty($arrSender[$id])) {
                        $arrSender[$id] = $arrTemplate['sender'];
                    }
                    if (!empty($arrTemplate['subject']) && empty($arrSubject[$id])) {
                        $arrSubject[$id] = str_replace('<DATE>', '[ORDER_DATE]', $arrTemplate['subject']);
                    }
                    if (isset($arrKey[$id])) {
                        // System templates get their default key
                        $arrTemplate['key'] = $arrKey[$id] . '_backup_by_update';
                        // Clear the protected flag, so the old templates
                        // may be removed at will
                        $arrTemplate['protected'] = false;
                    } else {
                        // Custom templates:
                        // Make the name lowercase and replace any non-letter
                        $new_key = preg_replace('/[^a-z]/', '_', strtolower($arrTemplate['name']));
                        // Keep it unique!  Use the ID if the key is taken
                        if (in_array($new_key, $arrKey)) {
                            $new_key = $id;
                        }
                        // Remember used keys, and replace the former ID
                        $arrKey[$id] = $new_key;
                        $arrTemplate['key'] = $new_key;
                    }
                    // Some installations may contain corrupt templates
                    // causing empty (0 or "") keys.  Those would make
                    // MailTemplate::store() fail!
                    if (empty($arrTemplate['key'])) {
                        $arrTemplate['key'] = uniqid() . '_backup_by_update)';
                    }
                    foreach ($arrTemplate as &$string) {
                        // Replace old <PLACEHOLDERS> with new [PLACEHOLDERS].
                        $string = preg_replace('/\\<([A-Z_]+)\\>/', '[$1]', $string);
                        // This is completely unreliable.
                        // Use the process as described above, not replacing the old templates,
                        // but adding the new ones instead.
                        //                    $string = str_replace('[ORDER_DATA]', $order_data, $string);
                        //                    $string = preg_replace('/[\\w\\s\\:]+\\[USERNAME\\](?:\\n|<br\\s?\\/?
                        //                          >)*[\\w\\s\\:]+\\[PASSWORD\\]/',
                        //                        $login_data, $string);
                    }
                    //                $arrTemplate['message_html'] = preg_replace(
                    //                    '/(?:\r|\n|\r\n)/', "<br />\n", $arrTemplate['message']);
                    $arrTemplate['lang_id'] = $lang_id;
                    if (!\Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', $arrTemplate)) {
                        throw new \Cx\Lib\Update_DatabaseException("Failed to store Mailtemplate");
                    }
                }
            }
            // Drop old Mail tables after successful migration
            \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail_content');
            \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail');
//.........这里部分代码省略.........
开发者ID:Niggu,项目名称:cloudrexx,代码行数:101,代码来源:ShopMail.class.php

示例5: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates old Shop Customers to the User accounts and adds
  * all new settings
  * @return  boolean     false     Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Customer
     $table_name_old = DBPREFIX . "module_shop_customers";
     // If the old Customer table is missing, the migration has completed
     // successfully already
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         return false;
     }
     // Ensure that the ShopSettings (including \Cx\Core\Setting) and Order tables
     // are ready first!
     //DBG::log("Customer::errorHandler(): Adding settings");
     ShopSettings::errorHandler();
     //        \Cx\Core\Country\Controller\Country::errorHandler(); // Called by Order::errorHandler();
     Order::errorHandler();
     Discount::errorHandler();
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     $objUser = \FWUser::getFWUserObject()->objUser;
     // Create new User_Profile_Attributes
     $index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop');
     if (!$index_notes) {
         //DBG::log("Customer::errorHandler(): Adding notes attribute...");
         //            $objProfileAttribute = new \User_Profile_Attribute();
         $objProfileAttribute = $objUser->objAttribute->getById(0);
         //DBG::log("Customer::errorHandler(): NEW notes attribute: ".var_export($objProfileAttribute, true));
         $objProfileAttribute->setNames(array(1 => 'Notizen', 2 => 'Notes', 3 => 'Notes', 4 => 'Notes', 5 => 'Notes', 6 => 'Notes'));
         $objProfileAttribute->setType('text');
         $objProfileAttribute->setMultiline(true);
         $objProfileAttribute->setParent(0);
         $objProfileAttribute->setProtection(array(1));
         //DBG::log("Customer::errorHandler(): Made notes attribute: ".var_export($objProfileAttribute, true));
         if (!$objProfileAttribute->store()) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'");
         }
         //Re initialize shop setting
         \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
         //DBG::log("Customer::errorHandler(): Stored notes attribute, ID ".$objProfileAttribute->getId());
         if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_notes', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_notes'))) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'notes' setting");
         }
         //DBG::log("Customer::errorHandler(): Stored notes attribute ID setting");
     }
     $index_group = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop');
     if (!$index_group) {
         //            $objProfileAttribute = new \User_Profile_Attribute();
         $objProfileAttribute = $objUser->objAttribute->getById(0);
         $objProfileAttribute->setNames(array(1 => 'Kundenrabattgruppe', 2 => 'Discount group', 3 => 'Kundenrabattgruppe', 4 => 'Kundenrabattgruppe', 5 => 'Kundenrabattgruppe', 6 => 'Kundenrabattgruppe'));
         $objProfileAttribute->setType('text');
         $objProfileAttribute->setParent(0);
         $objProfileAttribute->setProtection(array(1));
         if (!$objProfileAttribute->store()) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'");
         }
         //Re initialize shop setting
         \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
         if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_customer_group_id', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_customer_group_id'))) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'customer_group_id' setting");
         }
     }
     // For the migration, a temporary flag is needed in the orders table
     // in order to prevent mixing up old and new customer_id values.
     $table_order_name = DBPREFIX . "module_shop_orders";
     if (!\Cx\Lib\UpdateUtil::column_exist($table_order_name, 'migrated')) {
         $query = "\n                ALTER TABLE `{$table_order_name}`\n                  ADD `migrated` TINYINT(1) unsigned NOT NULL default 0";
         \Cx\Lib\UpdateUtil::sql($query);
     }
     // Create missing UserGroups for customers and resellers
     $objGroup = null;
     $group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop');
     if ($group_id_customer) {
         $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_customer);
     }
     if (!$objGroup || $objGroup->EOF) {
         $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Endkunden'));
     }
     if (!$objGroup || $objGroup->EOF) {
         $objGroup = new \UserGroup();
         $objGroup->setActiveStatus(true);
         $objGroup->setDescription('Online Shop Endkunden');
         $objGroup->setName('Shop Endkunden');
         $objGroup->setType('frontend');
     }
     //DBG::log("Group: ".var_export($objGroup, true));
     if (!$objGroup) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for customers");
     }
     //DBG::log("Customer::errorHandler(): Made customer usergroup: ".var_export($objGroup, true));
     if (!$objGroup->store() || !$objGroup->getId()) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for customers");
     }
     //DBG::log("Customer::errorHandler(): Stored customer usergroup, ID ".$objGroup->getId());
     \Cx\Core\Setting\Controller\Setting::set('usergroup_id_customer', $objGroup->getId());
//.........这里部分代码省略.........
开发者ID:Niggu,项目名称:cloudrexx,代码行数:101,代码来源:Customer.class.php

示例6: errorHandler

 /**
  * Fixes database errors.
  *
  * Also migrates settings from the old Shop settings table to \Cx\Core\Setting.
  * @return  boolean                 False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     global $_CONFIGURATION;
     // ShopSettings
     \Cx\Core\Setting\Controller\Setting::errorHandler();
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     $table_name = DBPREFIX . 'module_shop_config';
     $i = 0;
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         // Migrate all entries using the \Cx\Core\Setting\Controller\Setting class
         $query = "\n                SELECT `name`, `value`, `status`\n                  FROM " . DBPREFIX . "module_shop_config\n                 ORDER BY `id` ASC";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException('Failed to query old Shop settings', $query);
         }
         while (!$objResult->EOF) {
             $name = $objResult->fields['name'];
             $value = $objResult->fields['value'];
             $status = $objResult->fields['status'];
             $name_status = null;
             switch ($name) {
                 // OBSOLETE
                 case 'tax_default_id':
                 case 'tax_enabled':
                 case 'tax_included':
                 case 'tax_number':
                     // Ignore, do not migrate!
                     $name = null;
                     break;
                     // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\])
                 // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\])
                 case 'confirmation_emails':
                     $name = 'email_confirmation';
                     break;
                 case 'country_id':
                 case 'datatrans_merchant_id':
                 case 'datatrans_request_type':
                     break;
                 case 'datatrans_status':
                     $name = 'datatrans_active';
                     break;
                 case 'datatrans_use_testserver':
                 case 'email':
                 case 'fax':
                 case 'orderitems_amount_max':
                 case 'paypal_default_currency':
                 case 'postfinance_mobile_ijustwanttotest':
                 case 'postfinance_mobile_sign':
                 case 'postfinance_mobile_status':
                 case 'postfinance_mobile_webuser':
                 case 'product_sorting':
                 case 'saferpay_finalize_payment':
                 case 'saferpay_window_option':
                     break;
                 case 'shop_address':
                 case 'shop_company':
                 case 'shop_show_products_default':
                 case 'shop_thumbnail_max_height':
                 case 'shop_thumbnail_max_width':
                 case 'shop_thumbnail_quality':
                 case 'shop_weight_enable':
                     $name = preg_replace('/^shop_/', '', $name);
                     break;
                 case 'telephone':
                 case 'vat_default_id':
                 case 'vat_enabled_foreign_customer':
                 case 'vat_enabled_foreign_reseller':
                 case 'vat_enabled_home_customer':
                 case 'vat_enabled_home_reseller':
                 case 'vat_included_foreign_customer':
                 case 'vat_included_foreign_reseller':
                 case 'vat_included_home_customer':
                 case 'vat_included_home_reseller':
                 case 'vat_number':
                 case 'vat_other_id':
                     break;
                 case 'yellowpay_accepted_payment_methods':
                 case 'yellowpay_authorization_type':
                 case 'yellowpay_hash_seed':
                 case 'yellowpay_hash_signature_in':
                 case 'yellowpay_hash_signature_out':
                 case 'yellowpay_use_testserver':
                     $name = preg_replace('/^yellowpay(.*)$/', 'postfinance$1', $name);
                     break;
                 case 'yellowpay_id':
                     // Obsolete
                     $name = null;
                     break;
                     // VALUE & STATUS
                 // VALUE & STATUS
                 case 'paypal_account_email':
                     $name_status = 'paypal_active';
                     break;
//.........这里部分代码省略.........
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:101,代码来源:ShopSettings.class.php

示例7: errorHandler

 /**
  * Handle any error occurring in this class.
  *
  * Tries to fix known problems with the database table.
  * @global  mixed     $objDatabase    Database object
  * @return  boolean                   False.  Always.
  * @throws  Update_DatabaseException
  * @static
  * @author  Reto Kohli <reto.kohli@comvation.com>
  */
 static function errorHandler()
 {
     $table_name = DBPREFIX . "core_text";
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         $query = "\n                CREATE TABLE `" . DBPREFIX . "core_text` (\n                  `id` INT(10) UNSIGNED NOT NULL DEFAULT 0,\n                  `lang_id` INT(10) UNSIGNED NOT NULL DEFAULT 1,\n                  `section` VARCHAR(32) NULL DEFAULT NULL,\n                  `key` VARCHAR(255) NOT NULL,\n                  `text` TEXT NOT NULL,\n                  PRIMARY KEY `id` (`id`, `lang_id`, `section`, `key`(32)),\n                  FULLTEXT `text` (`text`)\n                ) ENGINE=MyISAM";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException('Failed to create Text table', $query);
         }
     }
     // More to come...
     return false;
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:23,代码来源:Text.class.php

示例8: errorHandler

 /**
  * Handles any kind of database error
  * @throws  Cx\Lib\Update_DatabaseException
  * @return  boolean                 False.  Always.
  */
 static function errorHandler()
 {
     // ShopCategory
     // Fix the Text and Settings table first
     \Text::errorHandler();
     ShopSettings::errorHandler();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $table_name = DBPREFIX . 'module_shop_categories';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'catid'), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'parentid'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'catsorting'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'catstatus'), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'default' => ''));
     $table_index = array('flags' => array('fields' => 'flags', 'type' => 'FULLTEXT'));
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'catname')) {
             // Migrate all ShopCategory names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             \Text::deleteByKey('Shop', self::TEXT_DESCRIPTION);
             $query = "\n                    SELECT `catid`, `catname`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query ShopCategory names");
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['catid'];
                 $name = $objResult->fields['catname'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate ShopCategory name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:39,代码来源:ShopCategory.class.php

示例9: errorHandler

 /**
  * Tries to recreate the database table(s) for the class
  *
  * Should be called whenever there's a problem with the database table.
  * @return  boolean             False.  Always.
  */
 static function errorHandler()
 {
     $table_name = DBPREFIX . 'core_country';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'alpha2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'alpha3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'is_active'));
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure);
     if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
         \Text::deleteByKey('core', self::TEXT_NAME);
         // Copy the Countries from the Shop module if possible
         if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . "module_shop_countries")) {
             $query = "\n                    SELECT `countries_id`, `countries_name`,\n                           `countries_iso_code_2`, `countries_iso_code_3`,\n                           `activation_status`\n                      FROM " . DBPREFIX . "module_shop_countries";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to to query Country names", $query);
             }
             $default_lang_id = \FWLanguage::getDefaultLangId();
             while (!$objResult->EOF) {
                 $id = $objResult->fields['countries_id'];
                 $name = $objResult->fields['countries_name'];
                 $alpha2 = $objResult->fields['countries_iso_code_2'];
                 $alpha3 = $objResult->fields['countries_iso_code_3'];
                 $active = $objResult->fields['activation_status'];
                 $ord = 0;
                 if ($id == 14) {
                     // fixing missing name
                     $name = 'Österreich';
                 }
                 if (!self::store($alpha2, $alpha3, $default_lang_id, $name, $ord, $active, $id)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate Country '{$name}'");
                 }
                 $objResult->MoveNext();
             }
             \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_countries');
         }
     }
     // USE FOR NEW INSTALLATIONS ONLY!
     // These records will lead to inconsistencies with Country references in
     // other tables otherwise.
     if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
         // Add new Country records if available
         if (file_exists(ASCMS_CORE_PATH . '/countries_iso_3166-2.php') && (include_once ASCMS_CORE_PATH . '/countries_iso_3166-2.php')) {
             //DBG::log("Country::errorHandler(): Included ISO file");
             $arrCountries = null;
             $ord = 0;
             foreach ($arrCountries as $country_id => $arrCountry) {
                 $name = $arrCountry[0];
                 $alpha2 = $arrCountry[1];
                 $alpha3 = $arrCountry[2];
                 // Not currently in use:
                 //                    $numeric = $arrCountry[3];
                 //                    $iso_full = $arrCountry[4];
                 // English (language ID 2) only!
                 if (!self::store($alpha2, $alpha3, 2, $name, ++$ord, true, $country_id)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to add Country '{$name}' from ISO file");
                 }
                 //DBG::log("Country::errorHandler(): Added Country ID $country_id: '$name'");
             }
         }
     }
     //DBG::activate(DBG_ADODB);
     // Add more languages from the countries_languages.php file,
     // if present
     $arrCountries = array();
     // $arrCountries is redefined in the file
     if (file_exists(ASCMS_CORE_PATH . '/countries_languages.php') && (include_once ASCMS_CORE_PATH . '/countries_languages.php')) {
         foreach ($arrCountries as $alpha2 => $arrLanguage) {
             //DBG::log("errorHandler: Looking for Alpha-2 $alpha2");
             $country_id = self::getIdByAlpha2($alpha2);
             if (!$country_id) {
                 // TODO: Fail or not?
                 continue;
             }
             foreach ($arrLanguage as $lang_id => $name) {
                 if (!\Text::replace($country_id, $lang_id, 'core', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to update Country '{$name}' from languages file");
                 }
                 //DBG::log("Country::errorHandler(): Added Country ID $country_id: language ID $lang_id");
             }
         }
     }
     \Cx\Core\Setting\Controller\Setting::init('core', 'country');
     \Cx\Core\Setting\Controller\Setting::add('numof_countries_per_page_backend', 30, 101);
     // More to come...
     // Always!
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:91,代码来源:Country.class.php

示例10: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates the old database structure to the new one
  * @return  boolean             False.  Always.
  */
 static function errorHandler()
 {
     // Order
     ShopSettings::errorHandler();
     \Cx\Core\Country\Controller\Country::errorHandler();
     $table_name = DBPREFIX . 'module_shop_order_items';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'order_items_id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'orderid'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'productid'), 'product_name' => array('type' => 'VARCHAR(255)', 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00'), 'quantity' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'vat_rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'vat_percent'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'));
     $table_index = array('order' => array('fields' => array('order_id')));
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_order_attributes';
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         $table_name_old = DBPREFIX . 'module_shop_order_items_attributes';
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'orders_items_attributes_id'), 'item_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'order_items_id'), 'attribute_name' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'product_option_name'), 'option_name' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'product_option_value'), 'price' => array('type' => 'DECIMAL(9,2)', 'unsigned' => false, 'default' => '0.00', 'renamefrom' => 'product_option_values_price'));
         $table_index = array('item_id' => array('fields' => array('item_id')));
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name);
     }
     // LSV
     $table_name = DBPREFIX . 'module_shop_lsv';
     $table_structure = array('order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'id'), 'holder' => array('type' => 'tinytext', 'default' => ''), 'bank' => array('type' => 'tinytext', 'default' => ''), 'blz' => array('type' => 'tinytext', 'default' => ''));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_orders';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'orderid'), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'customerid'), 'currency_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'selected_currency_id'), 'shipment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'shipping_id'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'customer_lang'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'order_status'), 'sum' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_order_sum'), 'vat_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'tax_price'), 'shipment_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_ship_price'), 'payment_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_payment_price'), 'billing_gender' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null), 'billing_company' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null), 'billing_firstname' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null), 'billing_lastname' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null), 'billing_address' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null), 'billing_city' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null), 'billing_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'default' => null), 'billing_country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'billing_phone' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null), 'billing_fax' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null), 'billing_email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'default' => null), 'gender' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_prefix'), 'company' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_company'), 'firstname' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_firstname'), 'lastname' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_lastname'), 'address' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_address'), 'city' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_city'), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_zip'), 'country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_country_id'), 'phone' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_phone'), 'ip' => array('type' => 'VARCHAR(50)', 'default' => '', 'renamefrom' => 'customer_ip'), 'host' => array('type' => 'VARCHAR(100)', 'default' => '', 'renamefrom' => 'customer_host'), 'browser' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'customer_browser'), 'note' => array('type' => 'TEXT', 'default' => '', 'renamefrom' => 'customer_note'), 'date_time' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'order_date'), 'modified_on' => array('type' => 'TIMESTAMP', 'default' => null, 'notnull' => false, 'renamefrom' => 'last_modified'), 'modified_by' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null));
     $table_index = array('status' => array('fields' => array('status')));
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // TODO: TEST
     // Migrate present Customer addresses to the new billing address fields.
     // Note that this method is also called in Customer::errorHandler() *before*
     // any Customer is modified.  Thus, we can safely depend on the old
     // Customer table in one way -- if it doesn't exist, all Orders and Customers
     // have been successfully migrated already.
     $table_name_customer = DBPREFIX . "module_shop_customers";
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_customer)) {
         // On the other hand, there may have been an error somewhere in between
         // altering the Orders table and moving Customers to the Users table.
         // So, to be on the safe side, we will only update Orders where the billing
         // address fields are all NULL, as is the case just after the alteration
         // of the Orders table above.
         // Also note that any inconsistencies involving missing Customer records will
         // be left over as-is and may later be handled in the backend.
         $objResult = \Cx\Lib\UpdateUtil::sql("\n                SELECT DISTINCT `customer_id`,\n                       `customer`.`prefix`,\n                       `customer`.`firstname`, `customer`.`lastname`,\n                       `customer`.`company`, `customer`.`address`,\n                       `customer`.`city`, `customer`.`zip`,\n                       `customer`.`country_id`,\n                       `customer`.`phone`, `customer`.`fax`,\n                       `customer`.`email`\n                  FROM `{$table_name}`\n                  JOIN `{$table_name_customer}` AS `customer`\n                    ON `customerid`=`customer_id`\n                 WHERE `billing_gender` IS NULL\n                   AND `billing_company` IS NULL\n                   AND `billing_firstname` IS NULL\n                   AND `billing_lastname` IS NULL\n                   AND `billing_address` IS NULL\n                   AND `billing_city` IS NULL\n                   AND `billing_zip` IS NULL\n                   AND `billing_country_id` IS NULL\n                   AND `billing_phone` IS NULL\n                   AND `billing_fax` IS NULL\n                   AND `billing_email` IS NULL");
         while ($objResult && !$objResult->EOF) {
             $customer_id = $objResult->fields['customer_id'];
             $gender = 'gender_unknown';
             if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) {
                 $gender = 'gender_female';
             } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) {
                 $gender = 'gender_male';
             }
             \Cx\Lib\UpdateUtil::sql("\n                    UPDATE `{$table_name}`\n                       SET `billing_gender`='" . addslashes($gender) . "',\n                           `billing_company`='" . addslashes($objResult->fields['company']) . "',\n                           `billing_firstname`='" . addslashes($objResult->fields['firstname']) . "',\n                           `billing_lastname`='" . addslashes($objResult->fields['lastname']) . "',\n                           `billing_address`='" . addslashes($objResult->fields['address']) . "',\n                           `billing_city`='" . addslashes($objResult->fields['city']) . "',\n                           `billing_zip`='" . addslashes($objResult->fields['zip']) . "',\n                           `billing_country_id`=" . intval($objResult->fields['country_id']) . ",\n                           `billing_phone`='" . addslashes($objResult->fields['phone']) . "',\n                           `billing_fax`='" . addslashes($objResult->fields['fax']) . "',\n                           `billing_email`='" . addslashes($objResult->fields['email']) . "'\n                     WHERE `customer_id`={$customer_id}\n                       AND `billing_gender` IS NULL\n                       AND `billing_company` IS NULL\n                       AND `billing_firstname` IS NULL\n                       AND `billing_lastname` IS NULL\n                       AND `billing_address` IS NULL\n                       AND `billing_city` IS NULL\n                       AND `billing_zip` IS NULL\n                       AND `billing_country_id` IS NULL\n                       AND `billing_phone` IS NULL\n                       AND `billing_fax` IS NULL\n                       AND `billing_email` IS NULL");
             $objResult->MoveNext();
         }
     }
     // Finally, update the migrated Order records with the proper gender
     // strings as used in the User class hierarchy as well
     $objResult = \Cx\Lib\UpdateUtil::sql("\n            SELECT `id`, `gender`\n              FROM `{$table_name}`\n             WHERE `gender` NOT IN\n                   ('gender_male', 'gender_female', 'gender_undefined')");
     while ($objResult && !$objResult->EOF) {
         $gender = 'gender_unknown';
         if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['gender'])) {
             $gender = 'gender_female';
         } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['gender'])) {
             $gender = 'gender_male';
         }
         \Cx\Lib\UpdateUtil::sql("\n                UPDATE `{$table_name}`\n                   SET `gender`='" . addslashes($gender) . "'\n                 WHERE `id`=" . $objResult->fields['id']);
         $objResult->MoveNext();
     }
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:76,代码来源:Order.class.php

示例11: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates text fields to the new structure
  * @return  boolean           False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Zones
     // Fix the Zone-Payment relation table
     $table_name = DBPREFIX . 'module_shop_rel_payment';
     $table_structure = array('zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Fix the Text table
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_zones';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'zones_id'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'activation_status'));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'zones_name')) {
             // Migrate all Zone names to the Text table first
             \Text::deleteByKey('Shop', self::TEXT_NAME);
             $query = "\n                    SELECT `zones_id`, `zones_name`\n                      FROM `{$table_name}`";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to query Zone names", $query);
             }
             while (!$objResult->EOF) {
                 $id = $objResult->fields['zones_id'];
                 $name = $objResult->fields['zones_name'];
                 if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Zone name '{$name}'");
                 }
                 $objResult->MoveNext();
             }
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     $table_name_old = DBPREFIX . 'module_shop_rel_shipment';
     $table_name_new = DBPREFIX . 'module_shop_rel_shipper';
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name_new) && \Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new);
     }
     $table_structure = array('shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'shipment_id'), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'zones_id'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name_new, $table_structure, $table_index);
     $table_name = DBPREFIX . 'module_shop_rel_countries';
     $table_structure = array('country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'countries_id'), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'));
     $table_index = array();
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     // Always
     return false;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:56,代码来源:Zones.class.php

示例12: getConflictedModules

function getConflictedModules($missedModules)
{
    $potentialMissedTables = array('blog' => array(DBPREFIX . 'module_blog_comments', DBPREFIX . 'module_blog_categories', DBPREFIX . 'module_blog_messages', DBPREFIX . 'module_blog_messages_lang', DBPREFIX . 'module_blog_message_to_category', DBPREFIX . 'module_blog_networks', DBPREFIX . 'module_blog_networks_lang', DBPREFIX . 'module_blog_settings', DBPREFIX . 'module_blog_votes'), 'calendar' => array(DBPREFIX . 'module_calendar', DBPREFIX . 'module_calendar_categories', DBPREFIX . 'module_calendar_form_data', DBPREFIX . 'module_calendar_form_fields', DBPREFIX . 'module_calendar_registrations', DBPREFIX . 'module_calendar_settings', DBPREFIX . 'module_calendar_style'), 'directory' => array(DBPREFIX . 'module_directory_categories', DBPREFIX . 'module_directory_dir', DBPREFIX . 'module_directory_inputfields', DBPREFIX . 'module_directory_levels', DBPREFIX . 'module_directory_mail', DBPREFIX . 'module_directory_rel_dir_cat', DBPREFIX . 'module_directory_rel_dir_level', DBPREFIX . 'module_directory_settings', DBPREFIX . 'module_directory_settings_google', DBPREFIX . 'module_directory_vote'), 'docsys' => array(DBPREFIX . 'module_docsys', DBPREFIX . 'module_docsys_categories', DBPREFIX . 'module_docsys_entry_category'), 'egov' => array(DBPREFIX . 'module_egov_configuration', DBPREFIX . 'module_egov_orders', DBPREFIX . 'module_egov_products', DBPREFIX . 'module_egov_product_calendar', DBPREFIX . 'module_egov_product_fields', DBPREFIX . 'module_egov_settings'), 'feed' => array(DBPREFIX . 'module_feed_category', DBPREFIX . 'module_feed_news', DBPREFIX . 'module_feed_newsml_association', DBPREFIX . 'module_feed_newsml_categories', DBPREFIX . 'module_feed_newsml_documents', DBPREFIX . 'module_feed_newsml_providers'), 'forum' => array(DBPREFIX . 'module_forum_access', DBPREFIX . 'module_forum_categories', DBPREFIX . 'module_forum_categories_lang', DBPREFIX . 'module_forum_notification', DBPREFIX . 'module_forum_postings', DBPREFIX . 'module_forum_rating', DBPREFIX . 'module_forum_settings', DBPREFIX . 'module_forum_statistics'), 'gallery' => array(DBPREFIX . 'module_gallery_categories', DBPREFIX . 'module_gallery_comments', DBPREFIX . 'module_gallery_language', DBPREFIX . 'module_gallery_language_pics', DBPREFIX . 'module_gallery_pictures', DBPREFIX . 'module_gallery_settings', DBPREFIX . 'module_gallery_votes'), 'guestbook' => array(DBPREFIX . 'module_guestbook', DBPREFIX . 'module_guestbook_settings'), 'livecam' => array(DBPREFIX . 'module_livecam', DBPREFIX . 'module_livecam_settings'), 'market' => array(DBPREFIX . 'module_market', DBPREFIX . 'module_market_categories', DBPREFIX . 'module_market_mail', DBPREFIX . 'module_market_paypal', DBPREFIX . 'module_market_settings', DBPREFIX . 'module_market_spez_fields'), 'memberdir' => array(DBPREFIX . 'module_memberdir_directories', DBPREFIX . 'module_memberdir_name', DBPREFIX . 'module_memberdir_settings', DBPREFIX . 'module_memberdir_values'), 'newsletter' => array(DBPREFIX . 'module_newsletter', DBPREFIX . 'module_newsletter_access_user', DBPREFIX . 'module_newsletter_attachment', DBPREFIX . 'module_newsletter_category', DBPREFIX . 'module_newsletter_confirm_mail', DBPREFIX . 'module_newsletter_email_link', DBPREFIX . 'module_newsletter_email_link_feedback', DBPREFIX . 'module_newsletter_rel_cat_news', DBPREFIX . 'module_newsletter_rel_usergroup_newsletter', DBPREFIX . 'module_newsletter_rel_user_cat', DBPREFIX . 'module_newsletter_settings', DBPREFIX . 'module_newsletter_template', DBPREFIX . 'module_newsletter_tmp_sending', DBPREFIX . 'module_newsletter_user', DBPREFIX . 'module_newsletter_user_title'), 'podcast' => array(DBPREFIX . 'module_podcast_category', DBPREFIX . 'module_podcast_medium', DBPREFIX . 'module_podcast_rel_category_lang', DBPREFIX . 'module_podcast_rel_medium_category', DBPREFIX . 'module_podcast_settings', DBPREFIX . 'module_podcast_template'), 'shop' => array(DBPREFIX . 'core_mail_template', DBPREFIX . 'core_country', DBPREFIX . 'module_shop_article_group', DBPREFIX . 'module_shop_attribute', DBPREFIX . 'module_shop_categories', DBPREFIX . 'module_shop_countries', DBPREFIX . 'module_shop_currencies', DBPREFIX . 'module_shop_customer_group', DBPREFIX . 'module_shop_discountgroup_count_name', DBPREFIX . 'module_shop_discountgroup_count_rate', DBPREFIX . 'module_shop_discount_coupon', DBPREFIX . 'module_shop_importimg', DBPREFIX . 'module_shop_lsv', DBPREFIX . 'module_shop_mail', DBPREFIX . 'module_shop_mail_content', DBPREFIX . 'module_shop_manufacturer', DBPREFIX . 'module_shop_option', DBPREFIX . 'module_shop_orders', DBPREFIX . 'module_shop_order_attributes', DBPREFIX . 'module_shop_order_items', DBPREFIX . 'module_shop_payment', DBPREFIX . 'module_shop_payment_processors', DBPREFIX . 'module_shop_pricelists', DBPREFIX . 'module_shop_products', DBPREFIX . 'module_shop_products_downloads', DBPREFIX . 'module_shop_rel_countries', DBPREFIX . 'module_shop_rel_customer_coupon', DBPREFIX . 'module_shop_rel_discount_group', DBPREFIX . 'module_shop_rel_payment', DBPREFIX . 'module_shop_rel_product_attribute', DBPREFIX . 'module_shop_rel_shipper', DBPREFIX . 'module_shop_shipment_cost', DBPREFIX . 'module_shop_shipper', DBPREFIX . 'module_shop_vat', DBPREFIX . 'module_shop_zones'), 'voting' => array(DBPREFIX . 'voting_additionaldata', DBPREFIX . 'voting_email', DBPREFIX . 'voting_rel_email_system', DBPREFIX . 'voting_results', DBPREFIX . 'voting_system'), 'downloads' => array(DBPREFIX . 'module_downloads_category', DBPREFIX . 'module_downloads_category_locale', DBPREFIX . 'module_downloads_download', DBPREFIX . 'module_downloads_download_locale', DBPREFIX . 'module_downloads_group', DBPREFIX . 'module_downloads_group_locale', DBPREFIX . 'module_downloads_rel_download_category', DBPREFIX . 'module_downloads_rel_download_download', DBPREFIX . 'module_downloads_rel_group_category', DBPREFIX . 'module_downloads_settings'), 'ecard' => array(DBPREFIX . 'module_ecard_ecards', DBPREFIX . 'module_ecard_settings'), 'jobs' => array(DBPREFIX . 'module_jobs', DBPREFIX . 'module_jobs_categories', DBPREFIX . 'module_jobs_location', DBPREFIX . 'module_jobs_rel_loc_jobs', DBPREFIX . 'module_jobs_settings'), 'knowledge' => array(DBPREFIX . 'module_knowledge_articles', DBPREFIX . 'module_knowledge_article_content', DBPREFIX . 'module_knowledge_categories', DBPREFIX . 'module_knowledge_categories_content', DBPREFIX . 'module_knowledge_settings', DBPREFIX . 'module_knowledge_tags', DBPREFIX . 'module_knowledge_tags_articles'), 'mediadir' => array(DBPREFIX . 'module_mediadir_categories', DBPREFIX . 'module_mediadir_categories_names', DBPREFIX . 'module_mediadir_comments', DBPREFIX . 'module_mediadir_entries', DBPREFIX . 'module_mediadir_forms', DBPREFIX . 'module_mediadir_form_names', DBPREFIX . 'module_mediadir_inputfields', DBPREFIX . 'module_mediadir_inputfield_names', DBPREFIX . 'module_mediadir_inputfield_types', DBPREFIX . 'module_mediadir_inputfield_verifications', DBPREFIX . 'module_mediadir_levels', DBPREFIX . 'module_mediadir_level_names', DBPREFIX . 'module_mediadir_mails', DBPREFIX . 'module_mediadir_mail_actions', DBPREFIX . 'module_mediadir_masks', DBPREFIX . 'module_mediadir_order_rel_forms_selectors', DBPREFIX . 'module_mediadir_rel_entry_categories', DBPREFIX . 'module_mediadir_rel_entry_inputfields', DBPREFIX . 'module_mediadir_rel_entry_inputfields_clean1', DBPREFIX . 'module_mediadir_rel_entry_levels', DBPREFIX . 'module_mediadir_settings', DBPREFIX . 'module_mediadir_settings_num_categories', DBPREFIX . 'module_mediadir_settings_num_entries', DBPREFIX . 'module_mediadir_settings_num_levels', DBPREFIX . 'module_mediadir_settings_perm_group_forms', DBPREFIX . 'module_mediadir_votes'));
    $conflictedModules = array();
    foreach ($missedModules as $module) {
        foreach ($potentialMissedTables[$module] as $table) {
            if (\Cx\Lib\UpdateUtil::table_exist($table)) {
                $result = \Cx\Lib\UpdateUtil::sql('SHOW TABLE STATUS WHERE `Name` = "' . $table . '"');
                if ($result && $result->RecordCount() > 0 && strpos($result->fields['Comment'], 'cx3upgrade') === false) {
                    $conflictedModules[$module][] = $table;
                }
            }
        }
    }
    return $conflictedModules;
}
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:16,代码来源:update.php

示例13: str_replace

            <label>[[TXT_FILESHARING_FILE_NAME]]</label>[[FILESHARING_FILE_NAME]]
        </p>
        <p>
            <input name="delete" type="submit" value="[[TXT_FILESHARING_CONFIRM_DELETE]]" />
        </p>
    </form>
    <!-- END confirm_delete -->
HTMLCODE;
    if (!preg_match('/<!--\\s+BEGIN\\s+confirm_delete\\s+-->.*<!--\\s+END\\s+confirm_delete\\s+-->/ms', $matches[0])) {
        return str_replace('<!-- END upload_form -->', $newHtmlCode, $matches[0]);
    } else {
        return $matches[0];
    }
};
\Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'filesharing', 'cmd' => ''), $search, $callback, array('content'), '3.1.0');
if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0') && (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_news_categories_catid') || \Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'module_news_categories_catid'))) {
    try {
        /************************************************
         * EXTENSION:    Categories as NestedSet         *
         * ADDED:        Contrexx v3.1.0                 *
         ************************************************/
        $nestedSetRootId = null;
        $count = null;
        $leftAndRight = 2;
        $sorting = 1;
        $level = 2;
        // add nested set columns
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories', array('catid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(11)', 'after' => 'catid'), 'left_id' => array('type' => 'INT(11)', 'after' => 'parent_id'), 'right_id' => array('type' => 'INT(11)', 'after' => 'left_id'), 'sorting' => array('type' => 'INT(11)', 'after' => 'right_id'), 'level' => array('type' => 'INT(11)', 'after' => 'sorting')));
        // add nested set root node and select its id
        $objResultRoot = \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_categories` (`catid`, `parent_id`, `left_id`, `right_id`, `sorting`, `level`) VALUES (0, 0, 0, 0, 0, 0)');
        if ($objResultRoot) {
开发者ID:Niggu,项目名称:cloudrexx,代码行数:31,代码来源:update3.php

示例14: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates the old Manufacturers to the new structure
  * @return  boolean             False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Manufacturer
     // Fix the Text table first
     \Text::errorHandler();
     $table_name = DBPREFIX . 'module_shop_manufacturer';
     // Note:  As this table uses a single column, the primary key will
     // have to be added separately below.  Otherwise, UpdateUtil::table()
     // will drop the id column first, then try to drop all the others,
     // which obviously won't work.
     // In that context, the "AUTO_INCREMENT" has to be dropped as well,
     // for that only applies to a primary key column.
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true));
     $table_index = array();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     if (\Cx\Lib\UpdateUtil::table_exist($table_name) && \Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) {
         // Get rid of bodies
         \Text::deleteByKey('Shop', self::TEXT_NAME);
         \Text::deleteByKey('Shop', self::TEXT_URI);
         // Migrate all Manufacturer text fields to the Text table
         $query = "\n                SELECT `id`, `name`, `url`\n                  FROM `" . DBPREFIX . "module_shop_manufacturer`";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         while (!$objResult->EOF) {
             $id = $objResult->fields['id'];
             $name = $objResult->fields['name'];
             $uri = $objResult->fields['url'];
             if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Manufacturer name '{$name}'");
             }
             if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Manufacturer URI '{$uri}'");
             }
             $objResult->MoveNext();
         }
     }
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
     \Cx\Lib\UpdateUtil::sql("\n            ALTER TABLE `{$table_name}`\n              ADD PRIMARY KEY (`id`)");
     \Cx\Lib\UpdateUtil::sql("\n            ALTER TABLE `{$table_name}`\n           CHANGE `id` `id` int(10) unsigned NOT NULL AUTO_INCREMENT");
     // Always
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:48,代码来源:Manufacturer.class.php

示例15: errorHandler

 /**
  * Handles database errors
  *
  * Also migrates old ProductAttribute to new Attribute structures,
  * including Text records.
  * @return  boolean   false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Attribute
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_name';
     $table_name_new = DBPREFIX . 'module_shop_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'display_type'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'name')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_ATTRIBUTE_NAME);
                 $query = "\n                        SELECT `id`, `name`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query Attribute names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['name'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_ATTRIBUTE_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Attribute name '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         //DBG::activate(DBG_ADODB);
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Attribute table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_value';
     $table_name_new = DBPREFIX . 'module_shop_option';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'name_id'), 'price' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'value')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_OPTION_NAME);
                 $query = "\n                        SELECT `id`, `value`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query option names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['value'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_OPTION_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate option Text '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Option table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes';
     $table_name_new = DBPREFIX . 'module_shop_rel_product_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'option_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'attributes_value_id'), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_id'));
         $table_index = array();
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Product-Attribute relation table {$table_name_old} to {$table_name_new}");
         }
     }
     // Always
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:90,代码来源:Attribute.class.php


注:本文中的Cx\Lib\UpdateUtil::table_exist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。