21 declare(strict_types=1);
62 if(!isset($defaultSchema, $array[
"schema"])){
63 throw new ConfigException(
"The attribute \"schema\" is missing in the MySQL settings");
65 return new MysqlCredentials($array[
"host"] ??
"127.0.0.1", $array[
"username"] ??
"root",
66 $array[
"password"] ??
"", $array[
"schema"] ?? $defaultSchema, $array[
"port"] ?? 3306, $array[
"socket"] ??
"");
79 public function __construct(
string $host,
string $username,
string $password,
string $schema,
int $port = 3306,
string $socket =
""){
81 $this->username = $username;
82 $this->password = $password;
83 $this->schema = $schema;
85 $this->socket = $socket;
96 $mysqli = @
new mysqli($this->host, $this->username, $this->password, $this->schema, $this->port, $this->socket);
97 if($mysqli->connect_error){
109 return "$this->username@$this->host:$this->port/schema,$this->socket";
119 "host" => $this->host,
120 "username" => $this->username,
121 "password" => str_repeat(
"*",
strlen($this->password)),
122 "schema" => $this->schema,
123 "port" => $this->port,
124 "socket" => $this->socket
130 "host" => $this->host,
131 "username" => $this->username,
132 "password" => $this->password,
133 "schema" => $this->schema,
134 "port" => $this->port,
135 "socket" => $this->socket
static fromArray(array $array, ?string $defaultSchema=null)
__construct(string $host, string $username, string $password, string $schema, int $port=3306, string $socket="")