本文整理汇总了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;
}
示例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;
}