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


PHP OA_DB::validateTableName方法代码示例

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


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

示例1: install

 /**
  * execute the installation steps
  *
  * @return boolean
  */
 function install($aConfig)
 {
     $this->oLogger->setLogFile('install.log');
     $this->oLogger->deleteLogFile();
     // Always use lower case prefixes for new installs
     $aConfig['table']['prefix'] = strtolower($aConfig['table']['prefix']);
     if ($aConfig['database']['localsocket'] == true) {
         $aConfig['database']['protocol'] = 'unix';
     } else {
         $aConfig['database']['protocol'] = 'tcp';
     }
     $this->aDsn['database'] = $aConfig['database'];
     $this->aDsn['table'] = $aConfig['table'];
     $this->oLogger->log('Installation started ' . OA::getNow());
     $this->oLogger->log('Attempting to connect to database ' . $this->aDsn['database']['name'] . ' with user ' . $this->aDsn['database']['username']);
     if (!$this->_createDatabase()) {
         $this->oLogger->logError('Installation failed to create the database ' . stripslashes($this->aDsn['database']['name']));
         return false;
     }
     $this->oLogger->log('Connected to database ' . $this->oDbh->connected_database_name);
     /**
      * validate table prefix before creating DB since it does not
      * make much sense to create a DB and then be unable to add tables
      */
     if (PEAR::isError(OA_DB::validateTableName($aConfig['table']['prefix']))) {
         $this->oLogger->logError('Illegal characters in table prefix ' . stripslashes($aConfig['table']['prefix']));
         return false;
     }
     if (!$this->checkExistingTables()) {
         if (!$this->oLogger->errorExists) {
             $this->oLogger->logError();
         }
         return false;
     }
     if (!$this->checkPermissionToCreateTable()) {
         $this->oLogger->logError('Insufficient database permissions or incorrect database settings to install');
         return false;
     }
     if (!$this->initDatabaseConnection()) {
         $this->oLogger->logError('Installation failed to connect to the database ' . $this->aDsn['database']['name']);
         $this->_dropDatabase();
         return false;
     }
     $aConfig = $this->initDatabaseParameters($aConfig);
     if (!$this->createCoreTables()) {
         $this->oLogger->logError('Installation failed to create the core tables');
         $this->_dropDatabase();
         return false;
     }
     $this->oLogger->log('Installation created the core tables');
     $this->oAuditor->setKeyParams(array('upgrade_name' => 'install_' . OA_VERSION, 'version_to' => OA_VERSION, 'version_from' => 0, 'logfile' => basename($this->oLogger->logFile)));
     if (!$this->oVersioner->putSchemaVersion('tables_core', $this->oTable->aDefinition['version'])) {
         $this->_auditInstallationFailure('Installation failed to update the schema version to ' . $oTable->aDefinition['version']);
         $this->_dropDatabase();
         return false;
     }
     $this->oLogger->log('Installation updated the schema version to ' . $this->oTable->aDefinition['version']);
     if (!$this->oVersioner->putApplicationVersion(OA_VERSION)) {
         $this->_auditInstallationFailure('Installation failed to update the application version to ' . OA_VERSION);
         $this->_dropDatabase();
         return false;
     }
     $this->oLogger->log('Installation updated the application version to ' . OA_VERSION);
     $this->oConfiguration->getInitialConfig();
     if (!$this->saveConfigDB($aConfig)) {
         $this->_auditInstallationFailure('Installation failed to write database details to the configuration file ' . $this->oConfiguration->configFile);
         if (file_exists($this->oConfiguration->configPath . $this->oConfiguration->configFile)) {
             @unlink($this->oConfiguration->configPath . $this->oConfiguration->configFile);
             $this->oLogger->log('Installation deleted the configuration file ' . $this->oConfiguration->configFile);
         }
         $this->_dropDatabase();
         return false;
     }
     $this->oAuditor->logAuditAction(array('description' => 'UPGRADE_COMPLETE', 'action' => UPGRADE_ACTION_UPGRADE_SUCCEEDED));
     if ($this->upgrading_from_milestone_version) {
         if (!$this->removeUpgradeTriggerFile()) {
             $this->oLogger->log('failed to remove the UPGRADE trigger file');
         }
     }
     return true;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:86,代码来源:Upgrade.php

示例2: testValidateTableName

 /**
  *  Method to test function validateDatabaseName in MDB2 Manager modules
  */
 function testValidateTableName()
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     OA::disableErrorHandling();
     $vals = array(0, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 96, 123, 124, 125, 126, 156, 255);
     //$pattern = '';
     foreach ($vals as $i) {
         //$pattern.= '\\x'.dechex($i);
         $result = OA_DB::validateTableName('o' . chr($i) . '_table');
         $this->assertTrue(PEAR::isError($result), 'chr(' . $i . ') /' . dechex($i));
     }
     if ($aConf['database']['type'] == 'mysql') {
         $result = OA_DB::validateTableName('abcdefghij1234567890123456789012345678901234567890123456789012345');
         //65 chars
         $this->assertTrue(PEAR::isError($result));
         $this->assertTrue(OA_DB::validateTableName('abcdefghij123456789012345678901234567890123456789012345678901234'));
         //64 chars
         $this->assertTrue(OA_DB::validateTableName('aBcDeFgHiJkLmNoPqRsTuVwXyZ_$1234567890'));
         $result = OA_DB::validateTableName('2_$');
         $this->assertFalse(PEAR::isError($result));
         $result = OA_DB::validateTableName('$_2');
         $this->assertFalse(PEAR::isError($result));
         $result = OA_DB::validateTableName('_$2');
         $this->assertFalse(PEAR::isError($result));
     }
     if ($aConf['database']['type'] == 'pgsql') {
         $result = OA_DB::validateTableName('abcdefghij123456789012345678901234567890123456789012345678901234');
         //64 chars
         $this->assertTrue(PEAR::isError($result));
         $this->assertTrue(OA_DB::validateTableName('abcdefghij12345678901234567890123456789012345678901234567890123'));
         //63 chars
         $result = OA_DB::validateTableName('0x_table');
         $this->assertTrue(PEAR::isError($result));
         $result = OA_DB::validateTableName(' x_table');
         $this->assertTrue(PEAR::isError($result));
         $this->assertTrue(OA_DB::validateTableName('aBcDeFgHiJkLmNoPqRsTuVwXyZ_$1234567890'));
         $result = OA_DB::validateTableName('2_$');
         $this->assertTrue(PEAR::isError($result));
         $result = OA_DB::validateTableName('$_2');
         $this->assertTrue(PEAR::isError($result));
         $result = OA_DB::validateTableName('_$2');
         $this->assertFalse(PEAR::isError($result));
     }
     OA::enableErrorHandling();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:48,代码来源:DB.db.test.php


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