本文整理汇总了PHP中Text::errorHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::errorHandler方法的具体用法?PHP Text::errorHandler怎么用?PHP Text::errorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::errorHandler方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: errorHandler
/**
* Handles any kind of database errors
*
* Includes updating the payments table (I guess from version 1.2.0(?),
* note that this is unconfirmed) to the current structure
* @return boolean False. Always.
* @throws Cx\Lib\Update_DatabaseException
*/
static function errorHandler()
{
// Payment
// Fix the Text and Zones tables first
\Text::errorHandler();
Zones::errorHandler();
\Yellowpay::errorHandler();
$table_name = DBPREFIX . 'module_shop_payment';
$table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs_free_sum'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => '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, 'name')) {
// Migrate all Payment names to the Text table first
\Text::deleteByKey('Shop', self::TEXT_NAME);
$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 Payment 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 Payment name '{$name}'");
}
$objResult->MoveNext();
}
}
}
\Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
// Update Payments that use obsolete PSPs:
// - 05, 'Internal_CreditCard'
// - 06, 'Internal_Debit',
// Uses 04, Internal
\Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=4 WHERE `processor_id` IN (5, 6)");
// - 07, 'Saferpay_Mastercard_Multipay_CAR',
// - 08, 'Saferpay_Visa_Multipay_CAR',
// Uses 01, Saferpay
\Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=1 WHERE `processor_id` IN (7, 8)");
$table_name = DBPREFIX . 'module_shop_rel_payment';
$table_structure = array('payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id'));
$table_index = array();
\Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
// Always
return false;
}
示例2: errorHandler
/**
* Handles database errors
*
* Also migrates text fields to the new structure
* @return boolean False. Always.
* @static
* @throws Cx\Lib\Update_DatabaseException
*/
static function errorHandler()
{
// Product
// Fix the Text, Discount, and Manufacturer tables first
\Text::errorHandler();
// Discount::errorHandler(); // Called by Customer::errorHandler();
Manufacturer::errorHandler();
$table_name = DBPREFIX . 'module_shop_products';
$table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discount_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'is_special_offer'), 'stock' => array('type' => 'INT(10)', 'default' => '10'), 'stock_visible' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'stock_visibility'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'date_start' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'startdate'), 'date_end' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'enddate'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'category_id' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'catid'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'manufacturer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'manufacturer'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'usergroup_ids' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_order'), 'distribution' => array('type' => 'VARCHAR(16)', 'default' => '', 'renamefrom' => 'handler'), 'picture' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'flags' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'minimum_order_quantity' => array('type' => 'INT(10)', 'unsigned' => false, 'default' => '0'));
$table_index = array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT'));
$default_lang_id = \FWLanguage::getDefaultLangId();
if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) {
// Migrate all Product strings to the Text table first
\Text::deleteByKey('Shop', self::TEXT_NAME);
\Text::deleteByKey('Shop', self::TEXT_SHORT);
\Text::deleteByKey('Shop', self::TEXT_LONG);
\Text::deleteByKey('Shop', self::TEXT_CODE);
\Text::deleteByKey('Shop', self::TEXT_URI);
\Text::deleteByKey('Shop', self::TEXT_KEYS);
$query = "\n SELECT `id`, `title`, `shortdesc`, `description`,\n `product_id`, `external_link`, `keywords`\n FROM `{$table_name}`";
$objResult = \Cx\Lib\UpdateUtil::sql($query);
if (!$objResult) {
throw new \Cx\Lib\Update_DatabaseException("Failed to query Product strings", $query);
}
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$name = $objResult->fields['title'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product name '{$name}'");
}
$short = $objResult->fields['shortdesc'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_SHORT, $short)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product short '{$short}'");
}
$long = $objResult->fields['description'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_LONG, $long)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product long '{$long}'");
}
$code = $objResult->fields['product_id'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CODE, $code)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product code '{$code}'");
}
$uri = $objResult->fields['external_link'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product uri '{$uri}'");
}
$keys = $objResult->fields['keywords'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_KEYS, $keys)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product keys '{$keys}'");
}
$objResult->MoveNext();
}
}
}
\Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
// Also fix Customer and some related tables
Customer::errorHandler();
// Always
return false;
}
示例3: _coreUpdate
//.........这里部分代码省略.........
*****************************************/
$path = ASCMS_DOCUMENT_ROOT . '/themes';
foreach (scandir($path) as $theme) {
if (!in_array($theme, array('.', '..', '.svn'))) {
$theme = $path . '/' . $theme;
$file = $theme . '/index.html';
if (file_exists($file)) {
try {
$objFile = new \Cx\Lib\FileSystem\File($file);
if (($data = $objFile->getData()) && !empty($data)) {
if (strpos($data, '{JAVASCRIPT}') === false) {
$data = preg_replace('/(\\s*)<\\/head>/ms', "\$1 {JAVASCRIPT}\$1</head>", $data);
if ($data) {
$objFile->write($data);
}
}
}
} catch (\Cx\Lib\FileSystem\FileSystemException $e) {
\DBG::msg($e->getMessage());
}
}
}
}
/********************************
* EXTENSION: Timezone *
* ADDED: Contrexx v3.0.0 *
********************************/
try {
\Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'log` CHANGE `datetime` `datetime` TIMESTAMP NULL DEFAULT "0000-00-00 00:00:00"');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/**********************************************************
* EXTENSION: Session garbage collector considers now *
* the individual lifetime of each session *
* (needed since remember me is implemented) *
* ADDED: Contrexx v3.0.1 *
***********************************************************/
try {
$arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'sessions');
if ($arrColumns === false) {
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'sessions'));
return false;
}
if (!isset($arrColumns['REMEMBER_ME'])) {
\Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'sessions` ADD `remember_me` INT(1) NOT NULL DEFAULT 0 AFTER `sessionid`');
}
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/**********************************************************
* EXTENSION: Delete old cache class which causes *
* classloader confliction. *
* ADDED: Contrexx v3.0.1 *
***********************************************************/
$path = ASCMS_DOCUMENT_ROOT . '/lib/FRAMEWORK/Cache.class.php';
if (file_exists($path)) {
if (!\Cx\Lib\FileSystem\FileSystem::delete_file($path)) {
setUpdateMsg('Die Datei "/lib/FRAMEWORK/Cache.class.php" konnte nicht gelöscht werden. Bitte löschen Sie diese manuell.', 'error');
setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_TRY_AGAIN'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
return false;
}
}
/********************************************************
* EXTENSION: Add new access id (178) to those groups *
* having access to the news (10) or *
* blog (119) module. *
* ADDED: Contrexx v3.1.0 *
********************************************************/
try {
\Cx\Lib\UpdateUtil::sql('
INSERT INTO `' . DBPREFIX . 'access_group_static_ids` (`access_id`, `group_id`)
SELECT 178, `group_id` FROM `' . DBPREFIX . 'access_group_static_ids` WHERE (`access_id` = 10) OR (`access_id` = 119) GROUP BY `group_id`
ON DUPLICATE KEY UPDATE `access_id` = `access_id`
');
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
try {
Text::errorHandler();
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
try {
\Cx\Core\Setting\Controller\Setting::errorHandler();
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
/********************************************************
* EXTENSION: ADD COMPONENTS TABLE *
* ADDED: Contrexx v3.1.0 *
********************************************************/
try {
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'component', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)', 'after' => 'id'), 'type' => array('type' => 'ENUM(\'core\',\'core_module\',\'module\')', 'after' => 'name')), null, 'InnoDB');
\Cx\Lib\UpdateUtil::sql("\n INSERT IGNORE INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES\n (70, 'Workbench', 'core_module'),\n (71, 'FrontendEditing', 'core_module'),\n (72, 'ContentManager', 'core')\n ");
} catch (\Cx\Lib\UpdateException $e) {
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: errorHandler
/**
* Handles many problems caused by the database table
* @return boolean False. Always.
*/
static function errorHandler()
{
\Text::errorHandler();
//DBG::activate(DBG_DB_FIREPHP);
$table_name = DBPREFIX . "core_mail_template";
$table_structure = array('key' => array('type' => 'TINYTEXT', 'default' => ''), 'section' => array('type' => 'TINYTEXT', 'notnull' => false, 'default' => null, 'renamefrom' => 'module_id'), 'text_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'text_name_id'), 'html' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0'), 'protected' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0'));
$table_index = array();
\Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
\Cx\Lib\UpdateUtil::sql("\n ALTER TABLE `{$table_name}`\n ADD PRIMARY KEY (`key` (32), `section` (32))");
//DBG::log("Mailtemplate::errorHandler(): Migrated table core_mail_template");
// Always!
return false;
}