Skip to content

Commit 080835b

Browse files
author
Wazabii
committed
Add mysql port as arg
1 parent 06876ef commit 080835b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Connect.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ class Connect
1616
private $dbname;
1717
private $charSetName;
1818
private $charset = "utf8mb4";
19+
private $port;
1920
private static $self;
2021
private static $prefix = "";
2122
private static $selectedDB;
2223
private static $mysqlVars;
2324

24-
public function __construct($server, $user, $pass, $dbname)
25+
public function __construct(string $server, string $user, string $pass, string $dbname, int $port = 3306)
2526
{
2627
$this->server = $server;
2728
$this->user = $user;
2829
$this->pass = $pass;
2930
$this->dbname = $dbname;
31+
$this->port = $port;
3032
self::$self = $this;
3133
}
3234

@@ -66,7 +68,7 @@ public static function setPrefix(string $prefix): void
6668
*/
6769
public function execute(): void
6870
{
69-
self::$selectedDB = new mysqli($this->server, $this->user, $this->pass, $this->dbname);
71+
self::$selectedDB = new mysqli($this->server, $this->user, $this->pass, $this->dbname, $this->port);
7072
if (mysqli_connect_error()) {
7173
throw new ConnectException('Failed to connect to MySQL: ' . mysqli_connect_error(), 1);
7274
}

0 commit comments

Comments
 (0)