public function exportDBCreate($db, $export_type, $db_alias = '')
{
global $crlf;
if (empty($db_alias)) {
$db_alias = $db;
}
if (isset($GLOBALS['sql_compatibility'])) {
$compat = $GLOBALS['sql_compatibility'];
} else {
$compat = 'NONE';
}
if (isset($GLOBALS['sql_drop_database'])) {
if (!PMA_exportOutputHandler('DROP DATABASE IF EXISTS ' . Util::backquoteCompat($db_alias, $compat, isset($GLOBALS['sql_backquotes'])) . ';' . $crlf)) {
return false;
}
}
if ($export_type == 'database' && !isset($GLOBALS['sql_create_database'])) {
return true;
}
$create_query = 'CREATE DATABASE IF NOT EXISTS ' . Util::backquoteCompat($db_alias, $compat, isset($GLOBALS['sql_backquotes']));
$collation = $GLOBALS['dbi']->getDbCollation($db);
if (mb_strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET ' . mb_substr($collation, 0, mb_strpos($collation, '_')) . ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
$create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) {
return false;
}
return $this->_exportUseStatement($db_alias, $compat);
}