當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Logging_Schema::fixSchemaDifferencesFor方法代碼示例

本文整理匯總了PHP中CRM_Logging_Schema::fixSchemaDifferencesFor方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Logging_Schema::fixSchemaDifferencesFor方法的具體用法?PHP CRM_Logging_Schema::fixSchemaDifferencesFor怎麽用?PHP CRM_Logging_Schema::fixSchemaDifferencesFor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Logging_Schema的用法示例。


在下文中一共展示了CRM_Logging_Schema::fixSchemaDifferencesFor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: alterFieldSQL

 static function alterFieldSQL(&$params, $indexExist = FALSE)
 {
     $sql = str_repeat(' ', 8);
     $sql .= "ALTER TABLE {$params['table_name']}";
     // lets suppress the required flag, since that can cause sql issue
     $params['required'] = FALSE;
     switch ($params['operation']) {
         case 'add':
             $separator = "\n";
             $prefix = "ADD ";
             $sql .= self::buildFieldSQL($params, $separator, "ADD COLUMN ");
             $separator = ",\n";
             $sql .= self::buildPrimaryKeySQL($params, $separator, "ADD PRIMARY KEY ");
             $sql .= self::buildSearchIndexSQL($params, $separator, "ADD INDEX ");
             $sql .= self::buildForeignKeySQL($params, $separator, "ADD ", $params['table_name']);
             break;
         case 'modify':
             $separator = "\n";
             $prefix = "MODIFY ";
             $sql .= self::buildFieldSQL($params, $separator, $prefix);
             $separator = ",\n";
             $sql .= self::buildSearchIndexSQL($params, $separator, "ADD INDEX ", $indexExist);
             break;
         case 'delete':
             $sql .= " DROP COLUMN `{$params['name']}`";
             if (CRM_Utils_Array::value('primary', $params)) {
                 $sql .= ", DROP PRIMARY KEY";
             }
             if (CRM_Utils_Array::value('fk_table_name', $params)) {
                 $sql .= ", DROP FOREIGN KEY FK_{$params['fkName']}";
             }
             break;
     }
     // CRM-7007: do not i18n-rewrite this query
     $dao = CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE);
     $dao->free();
     $config = CRM_Core_Config::singleton();
     if ($config->logging) {
         // logging support: if we’re adding a column (but only then!) make sure the potential relevant log table gets a column as well
         if ($params['operation'] == 'add') {
             $logging = new CRM_Logging_Schema();
             $logging->fixSchemaDifferencesFor($params['table_name'], array($params['name']));
         } elseif ($params['operation'] == 'delete') {
             // CRM-7293: if we’re dropping a column – rebuild triggers
             CRM_Core_DAO::triggerRebuild($params['table_name']);
         }
     }
     return TRUE;
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:49,代碼來源:SchemaHandler.php

示例2: alterFieldSQL

 /**
  * @param array $params
  * @param bool $indexExist
  * @param bool $triggerRebuild
  *
  * @return bool
  */
 public static function alterFieldSQL(&$params, $indexExist = FALSE, $triggerRebuild = TRUE)
 {
     $sql = str_repeat(' ', 8);
     $sql .= "ALTER TABLE {$params['table_name']}";
     // lets suppress the required flag, since that can cause sql issue
     $params['required'] = FALSE;
     switch ($params['operation']) {
         case 'add':
             $separator = "\n";
             $prefix = "ADD ";
             $sql .= self::buildFieldSQL($params, $separator, "ADD COLUMN ");
             $separator = ",\n";
             $sql .= self::buildPrimaryKeySQL($params, $separator, "ADD PRIMARY KEY ");
             $sql .= self::buildSearchIndexSQL($params, $separator, "ADD INDEX ");
             $sql .= self::buildForeignKeySQL($params, $separator, "ADD ", $params['table_name']);
             break;
         case 'modify':
             $separator = "\n";
             $prefix = "MODIFY ";
             $sql .= self::buildFieldSQL($params, $separator, $prefix);
             $separator = ",\n";
             $sql .= self::buildSearchIndexSQL($params, $separator, "ADD INDEX ", $indexExist);
             break;
         case 'delete':
             $sql .= " DROP COLUMN `{$params['name']}`";
             if (!empty($params['primary'])) {
                 $sql .= ", DROP PRIMARY KEY";
             }
             if (!empty($params['fk_table_name'])) {
                 $sql .= ", DROP FOREIGN KEY FK_{$params['fkName']}";
             }
             break;
     }
     // CRM-7007: do not i18n-rewrite this query
     $dao = CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE);
     $dao->free();
     $config = CRM_Core_Config::singleton();
     if ($config->logging) {
         // CRM-16717 not sure why this was originally limited to add.
         // For example custom tables can have field length changes - which need to flow through to logging.
         // Are there any modifies we DON'T was to call this function for (& shouldn't it be clever enough to cope?)
         if ($params['operation'] == 'add' || $params['operation'] == 'modify') {
             $logging = new CRM_Logging_Schema();
             $logging->fixSchemaDifferencesFor($params['table_name'], array(trim($prefix) => array($params['name'])), FALSE);
         }
     }
     if ($triggerRebuild) {
         CRM_Core_DAO::triggerRebuild($params['table_name']);
     }
     return TRUE;
 }
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:58,代碼來源:SchemaHandler.php


注:本文中的CRM_Logging_Schema::fixSchemaDifferencesFor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。