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