[*] IN : only display the button to create the database if you can actually create the database
This commit is contained in:
@@ -46,14 +46,17 @@ class DbPDOCore extends Db
|
||||
return new PDO($dsn, $user, $password, array(PDO::ATTR_TIMEOUT => $timeout, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
|
||||
}
|
||||
|
||||
public static function createDatabase($host, $user, $password, $dbname)
|
||||
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
|
||||
{
|
||||
try {
|
||||
$link = DbPDO::_getPDO($host, $user, $password, false);
|
||||
return $link->exec('CREATE DATABASE `'.bqSQL($dbname).'`');
|
||||
$success = $link->exec('CREATE DATABASE `'.bqSQL($dbname).'`');
|
||||
if ($dropit)
|
||||
$success &= $link->exec('DROP DATABASE `'.bqSQL($dbname).'`');
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
$success = false;
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user