[*] IN : the installer can now attempt to create the database for you
This commit is contained in:
+14
-1
@@ -52,6 +52,18 @@ class DbMySQLiCore extends Db
|
||||
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
public static function createDatabase($host, $user, $password, $dbname)
|
||||
{
|
||||
if (strpos($host, ':') !== false)
|
||||
{
|
||||
list($host, $port) = explode(':', $host);
|
||||
$link = @new mysqli($host, $this->user, $this->password, null, $port);
|
||||
}
|
||||
else
|
||||
$link = @new mysqli($host, $user, $password);
|
||||
return $link->query('CREATE DATABASE `'.bqSQL($dbname).'`');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DbCore::disconnect()
|
||||
@@ -169,7 +181,8 @@ class DbMySQLiCore extends Db
|
||||
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
|
||||
return 1;
|
||||
|
||||
if (!$link->real_connect($server, $user, $pwd, $db))
|
||||
// There is an @ because mysqli throw a warning when the database does not exists
|
||||
if (!@$link->real_connect($server, $user, $pwd, $db))
|
||||
return (mysqli_connect_errno() == 1049) ? 2 : 1;
|
||||
|
||||
$link->close();
|
||||
|
||||
Reference in New Issue
Block a user