public function getUniversalMysqliDatabase(Plugin $ctx, $disableOnFailure = true)
{
if (!$this->universalMysqli instanceof \mysqli) {
$data = $this->getXEconConfiguration()->getUniMysqlDetails();
$this->universalMysqli = @new \mysqli($data["host"], $data["username"], $data["password"], $data["database"], $data["port"]);
if ($this->universalMysqli->connect_error) {
$ctx->getLogger()->critical("Failed to connect to the xEcon universal MySQL database! " . "Reason: {$this->universalMysqli->connect_error}");
if ($disableOnFailure) {
if ($ctx !== $this) {
$desc = $ctx->getDescription();
$this->getLogger()->critical("Disabling {$desc->getFullName()} by " . implode(", ", $desc->getAuthors()) . " because the required universal " . "MySQL database cannot be connected to.");
} else {
$this->getLogger()->critical("Disabling due to required universal MySQL database not connectable.");
}
$ctx->getPluginLoader()->disablePlugin($ctx);
}
$this->universalMysqli = null;
}
}
return $this->universalMysqli;
}