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


PHP DatabaseConnection::setDatabaseName方法代码示例

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


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

示例1: getDatabaseList

 /**
  * Returns list of available databases (with access-check based on username/password)
  *
  * @param bool $initialInstallation TRUE if first installation is in progress, FALSE if upgrading or usual access
  * @return array List of available databases
  */
 protected function getDatabaseList($initialInstallation)
 {
     $this->initializeDatabaseConnection();
     $databaseArray = $this->databaseConnection->admin_get_dbs();
     // Remove mysql organizational tables from database list
     $reservedDatabaseNames = array('mysql', 'information_schema', 'performance_schema');
     $allPossibleDatabases = array_diff($databaseArray, $reservedDatabaseNames);
     // If we are upgrading we show *all* databases the user has access to
     if ($initialInstallation === false) {
         return $allPossibleDatabases;
     } else {
         // In first installation we show all databases but disable not empty ones (with tables)
         $databases = array();
         foreach ($allPossibleDatabases as $database) {
             $this->databaseConnection->setDatabaseName($database);
             $this->databaseConnection->sql_select_db();
             $existingTables = $this->databaseConnection->admin_get_tables();
             $databases[] = array('name' => $database, 'tables' => count($existingTables));
         }
         return $databases;
     }
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:28,代码来源:DatabaseSelect.php

示例2: selectDatabase

 /**
  * Selects the database depending on TYPO3 version.
  *
  * @param string $databaseName the name of the database to select
  * @param DatabaseConnection $database database object to process the change
  *
  * @return bool
  */
 protected function selectDatabase($databaseName, DatabaseConnection $database)
 {
     $database->setDatabaseName($databaseName);
     $result = $database->sql_select_db();
     return $result;
 }
开发者ID:jacobsenj,项目名称:phpunit,代码行数:14,代码来源:TestCase.php

示例3: selectDbReturnsFalse

 /**
  * @test
  * @expectedException \RuntimeException
  * @expectedExceptionMessage TYPO3 Fatal Error: Cannot connect to the current database, "Foo"!
  * @return void
  */
 public function selectDbReturnsFalse()
 {
     $this->subject->setDatabaseName('Foo');
     $this->assertFalse($this->subject->sql_select_db());
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:11,代码来源:DatabaseConnectionTest.php


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