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


PHP CRM_Core_DAO::requireSafeDBName方法代码示例

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


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

示例1: checkdatabase

 /**
  * Just check that the database configuration is okay.
  * @param $databaseConfig
  * @param $dbName
  */
 public function checkdatabase($databaseConfig, $dbName)
 {
     if ($this->requireFunction('mysqli_connect', array(ts("PHP Configuration"), ts("MySQL support"), ts("MySQL support not included in PHP.")))) {
         $this->requireMySQLServer($databaseConfig['server'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Does the server exist?"), ts("Can't find the a MySQL server on '%1'.", array(1 => $databaseConfig['server'])), $databaseConfig['server']));
         if ($this->requireMysqlConnection($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Are the access credentials correct?"), ts("That username/password doesn't work")))) {
             @$this->requireMySQLVersion("5.1", array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("MySQL version at least %1", array(1 => '5.1')), ts("MySQL version %1 or higher is required, you are running MySQL %2.", array(1 => '5.1', 2 => mysqli_get_server_info($this->conn))), ts("MySQL %1", array(1 => mysqli_get_server_info($this->conn)))));
             $this->requireMySQLAutoIncrementIncrementOne($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Is auto_increment_increment set to 1"), ts("An auto_increment_increment value greater than 1 is not currently supported. Please see issue CRM-7923 for further details and potential workaround.")));
             $testDetails = array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Is the provided database name valid?"), ts("The database name provided is not valid. Please use only 0-9, a-z, A-Z, _ and - as characters in the name."));
             if (!CRM_Core_DAO::requireSafeDBName($databaseConfig['database'])) {
                 $this->error($testDetails);
                 return FALSE;
             } else {
                 $this->testing($testDetails);
             }
             $this->requireMySQLThreadStack($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'], self::MINIMUM_THREAD_STACK, array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Does MySQL thread_stack meet minimum (%1k)", array(1 => self::MINIMUM_THREAD_STACK)), ""));
         }
         $onlyRequire = $dbName == 'Drupal' || $dbName == 'Backdrop' ? TRUE : FALSE;
         $this->requireDatabaseOrCreatePermissions($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Can I access/create the database?"), ts("I can't create new databases and the database '%1' doesn't exist.", array(1 => $databaseConfig['database']))), $onlyRequire);
         if ($dbName != 'Drupal' && $dbName != 'Backdrop') {
             $this->requireMySQLInnoDB($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts("Can I access/create InnoDB tables in the database?"), ts("Unable to create InnoDB tables. MySQL InnoDB support is required for CiviCRM but is either not available or not enabled in this MySQL database server.")));
             $this->requireMySQLTempTables($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts('Can I create temporary tables in the database?'), ts('Unable to create temporary tables. This MySQL user is missing the CREATE TEMPORARY TABLES privilege.')));
             $this->requireMySQLLockTables($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts('Can I create lock tables in the database?'), ts('Unable to lock tables. This MySQL user is missing the LOCK TABLES privilege.')));
             $this->requireMySQLTrigger($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], $databaseConfig['database'], array(ts("MySQL %1 Configuration", array(1 => $dbName)), ts('Can I create triggers in the database?'), ts('Unable to create triggers. This MySQL user is missing the CREATE TRIGGERS  privilege.')));
         }
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:31,代码来源:index.php

示例2: testRequireSafeDBName

 /**
  * requireSafeDBName() method (to check valid database name)
  */
 public function testRequireSafeDBName()
 {
     $databases = array('testdb' => TRUE, 'test_db' => TRUE, 'TEST_db' => TRUE, '123testdb' => TRUE, 'test12db34' => TRUE, 'test_12_db34' => TRUE, 'test-db' => TRUE, 'test;db' => FALSE, 'test*&db' => FALSE, 'testdb;Delete test' => FALSE, '123456' => FALSE, 'test#$%^&*' => FALSE);
     $testDetails = array();
     foreach ($databases as $database => $val) {
         $this->assertEquals(CRM_Core_DAO::requireSafeDBName($database), $val);
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:11,代码来源:DAOTest.php


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