本文整理汇总了PHP中CRM_Logging_Schema::createTriggersFor方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Logging_Schema::createTriggersFor方法的具体用法?PHP CRM_Logging_Schema::createTriggersFor怎么用?PHP CRM_Logging_Schema::createTriggersFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Logging_Schema
的用法示例。
在下文中一共展示了CRM_Logging_Schema::createTriggersFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
// 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') {
require_once 'CRM/Logging/Schema.php';
$logging = new CRM_Logging_Schema();
$logging->fixSchemaDifferencesFor($params['table_name'], array($params['name']));
// CRM-7293: if we’re dropping a column – rebuild triggers
} elseif ($params['operation'] == 'delete') {
require_once 'CRM/Logging/Schema.php';
$logging = new CRM_Logging_Schema();
$logging->createTriggersFor($params['table_name']);
}
return true;
}