[*] IN : only display the button to create the database if you can actually create the database

This commit is contained in:
Damien Metzger
2013-07-03 11:28:55 +02:00
parent bfa2f33c65
commit 5789e6eb51
4 changed files with 23 additions and 13 deletions
+6 -3
View File
@@ -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;
}
/**