Allow setting of alternative MySQL port
This commit is contained in:
parent
bc1265a828
commit
84d7838e13
@ -41,13 +41,24 @@
|
||||
$fullUrl = $parts[1];
|
||||
$urlParts = explode('/', $fullUrl);
|
||||
$host = $urlParts[0];
|
||||
$port = 3306;
|
||||
|
||||
// check is port has been declared
|
||||
if (strpos($host, ':') !== false)
|
||||
{
|
||||
$hostParts = explode(':', $host);
|
||||
$host = $hostParts[0];
|
||||
$port = $hostParts[1];
|
||||
}
|
||||
|
||||
$database = $urlParts[1];
|
||||
|
||||
$name = $parts[0];
|
||||
$username = $parts[2];
|
||||
$password = $parts[3];
|
||||
|
||||
$connection = new mysqli($host, $username, $password, $database);
|
||||
echo $port;
|
||||
$connection = new mysqli($host, $username, $password, $database, $port);
|
||||
|
||||
if ($connection->connect_error) {
|
||||
die("Connection \"$name\" failed: $connection->connect_error");
|
||||
|
Loading…
Reference in New Issue
Block a user