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


PHP CRM_Core_DAO::shortenSQLName方法代码示例

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


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

示例1: dropTriggers

 /**
  * Drop triggers for all logged tables.
  */
 public function dropTriggers($tableName = NULL)
 {
     $dao = new CRM_Core_DAO();
     if ($tableName) {
         $tableNames = array($tableName);
     } else {
         $tableNames = $this->tables;
     }
     foreach ($tableNames as $table) {
         $validName = CRM_Core_DAO::shortenSQLName($table, 48, TRUE);
         // before triggers
         $dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_before_insert");
         $dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_before_update");
         $dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_before_delete");
         // after triggers
         $dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_insert");
         $dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_update");
         $dao->executeQuery("DROP TRIGGER IF EXISTS {$validName}_after_delete");
     }
     // now lets also be safe and drop all triggers that start with
     // civicrm_ if we are dropping all triggers
     // we need to do this to capture all the leftover triggers since
     // we did the shortening trigger name for CRM-11794
     if ($tableName === NULL) {
         $triggers = $dao->executeQuery("SHOW TRIGGERS LIKE 'civicrm_%'");
         while ($triggers->fetch()) {
             // note that drop trigger has a weird syntax and hence we do not
             // send the trigger name as a string (i.e. its not quoted
             $dao->executeQuery("DROP TRIGGER IF EXISTS {$triggers->Trigger}");
         }
     }
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:35,代码来源:Schema.php

示例2: testShortenSQLName

 /**
  * @dataProvider sqlNameDataProvider
  */
 function testShortenSQLName($inputData, $length, $makeRandom, $expectedResult)
 {
     $this->assertEquals($expectedResult, CRM_Core_DAO::shortenSQLName($inputData, $length, $makeRandom));
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:7,代码来源:DAOTest.php

示例3: createTriggers

 /**
  * @param array $info
  *   per hook_civicrm_triggerInfo.
  * @param string $onlyTableName
  *   the specific table requiring a rebuild; or NULL to rebuild all tables.
  */
 public static function createTriggers(&$info, $onlyTableName = NULL)
 {
     // Validate info array, should probably raise errors?
     if (is_array($info) == FALSE) {
         return;
     }
     $triggers = array();
     // now enumerate the tables and the events and collect the same set in a different format
     foreach ($info as $value) {
         // clean the incoming data, skip malformed entries
         // TODO: malformed entries should raise errors or get logged.
         if (isset($value['table']) == FALSE || isset($value['event']) == FALSE || isset($value['when']) == FALSE || isset($value['sql']) == FALSE) {
             continue;
         }
         if (is_string($value['table']) == TRUE) {
             $tables = array($value['table']);
         } else {
             $tables = $value['table'];
         }
         if (is_string($value['event']) == TRUE) {
             $events = array(strtolower($value['event']));
         } else {
             $events = array_map('strtolower', $value['event']);
         }
         $whenName = strtolower($value['when']);
         foreach ($tables as $tableName) {
             if (!isset($triggers[$tableName])) {
                 $triggers[$tableName] = array();
             }
             foreach ($events as $eventName) {
                 $template_params = array('{tableName}', '{eventName}');
                 $template_values = array($tableName, $eventName);
                 $sql = str_replace($template_params, $template_values, $value['sql']);
                 $variables = str_replace($template_params, $template_values, CRM_Utils_Array::value('variables', $value));
                 if (!isset($triggers[$tableName][$eventName])) {
                     $triggers[$tableName][$eventName] = array();
                 }
                 if (!isset($triggers[$tableName][$eventName][$whenName])) {
                     // We're leaving out cursors, conditions, and handlers for now
                     // they are kind of dangerous in this context anyway
                     // better off putting them in stored procedures
                     $triggers[$tableName][$eventName][$whenName] = array('variables' => array(), 'sql' => array());
                 }
                 if ($variables) {
                     $triggers[$tableName][$eventName][$whenName]['variables'][] = $variables;
                 }
                 $triggers[$tableName][$eventName][$whenName]['sql'][] = $sql;
             }
         }
     }
     // now spit out the sql
     foreach ($triggers as $tableName => $tables) {
         if ($onlyTableName != NULL && $onlyTableName != $tableName) {
             continue;
         }
         foreach ($tables as $eventName => $events) {
             foreach ($events as $whenName => $parts) {
                 $varString = implode("\n", $parts['variables']);
                 $sqlString = implode("\n", $parts['sql']);
                 $validName = CRM_Core_DAO::shortenSQLName($tableName, 48, TRUE);
                 $triggerName = "{$validName}_{$whenName}_{$eventName}";
                 $triggerSQL = "CREATE TRIGGER {$triggerName} {$whenName} {$eventName} ON {$tableName} FOR EACH ROW BEGIN {$varString} {$sqlString} END";
                 CRM_Core_DAO::executeQuery("DROP TRIGGER IF EXISTS {$triggerName}");
                 CRM_Core_DAO::executeQuery($triggerSQL, array(), TRUE, NULL, FALSE, FALSE);
             }
         }
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:74,代码来源:DAO.php

示例4: dropTriggers

 /**
  * Drop triggers for all logged tables.
  *
  * @param string $tableName
  */
 public function dropTriggers($tableName = NULL)
 {
     /** @var \Civi\Core\SqlTriggers $sqlTriggers */
     $sqlTriggers = Civi::service('sql_triggers');
     $dao = new CRM_Core_DAO();
     if ($tableName) {
         $tableNames = array($tableName);
     } else {
         $tableNames = $this->tables;
     }
     foreach ($tableNames as $table) {
         $validName = CRM_Core_DAO::shortenSQLName($table, 48, TRUE);
         // before triggers
         $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$validName}_before_insert");
         $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$validName}_before_update");
         $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$validName}_before_delete");
         // after triggers
         $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$validName}_after_insert");
         $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$validName}_after_update");
         $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$validName}_after_delete");
     }
     // now lets also be safe and drop all triggers that start with
     // civicrm_ if we are dropping all triggers
     // we need to do this to capture all the leftover triggers since
     // we did the shortening trigger name for CRM-11794
     if ($tableName === NULL) {
         $triggers = $dao->executeQuery("SHOW TRIGGERS LIKE 'civicrm_%'");
         while ($triggers->fetch()) {
             $sqlTriggers->enqueueQuery("DROP TRIGGER IF EXISTS {$triggers->Trigger}");
         }
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:37,代码来源:Schema.php


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