本文整理匯總了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::admin_get_dbs方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseConnection::admin_get_dbs方法的具體用法?PHP DatabaseConnection::admin_get_dbs怎麽用?PHP DatabaseConnection::admin_get_dbs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Core\Database\DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::admin_get_dbs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: adminGetDbsReturnsAllDatabases
/**
* @test
*
* @return void
*/
public function adminGetDbsReturnsAllDatabases()
{
/** @noinspection SqlResolve */
$databases = $this->subject->admin_query('SELECT SCHEMA_NAME FROM information_schema.SCHEMATA');
$result = $this->subject->admin_get_dbs();
$this->assertSame(count($result), $databases->num_rows);
$i = 0;
while ($database = $databases->fetch_assoc()) {
$this->assertSame($database['SCHEMA_NAME'], $result[$i]);
$i++;
}
}
示例2: 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;
}
}