feat: allow for SQL server port specification
This commit is contained in:
parent
0d9bedcaca
commit
9e855fba36
3 changed files with 20 additions and 16 deletions
|
@ -9,24 +9,29 @@ class MySQLAdapter {
|
|||
function __construct() {
|
||||
$db_params = json_decode(file_get_contents('secrets/db.json'), true);
|
||||
|
||||
if(null !== getenv('MYSQL_HOST')) {
|
||||
$this->raw = mysqli_connect(getenv('MYSQL_HOST'),
|
||||
getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'), getenv('MYSQL_DATABASE'));
|
||||
}
|
||||
else {
|
||||
$this->raw = mysqli_connect($db_params['MYSQL_HOST'],
|
||||
$db_params['MYSQL_USER'], $db_params['MYSQL_PASSWORD'], $db_params['MYSQL_DATABASE']);
|
||||
}
|
||||
|
||||
$this->data_directory = 'raw';
|
||||
|
||||
if (!$this->raw)
|
||||
{
|
||||
try {
|
||||
if(false !== getenv('MYSQL_HOST')) {
|
||||
$this->raw = mysqli_connect(getenv('MYSQL_HOST'),
|
||||
getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'),
|
||||
getenv('MYSQL_DATABASE'),
|
||||
getenv('MYSQL_PORT'));
|
||||
}
|
||||
else {
|
||||
$this->raw = mysqli_connect($db_params['MYSQL_HOST'],
|
||||
$db_params['MYSQL_USER'], $db_params['MYSQL_PASSWORD'],
|
||||
$db_params['MYSQL_DATABASE'],
|
||||
$db_params['MYSQL_PORT']);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
echo 'Connection failed<br>';
|
||||
echo 'Error number: ' . mysqli_connect_errno() . '<br>';
|
||||
echo 'Error message: ' . mysqli_connect_error() . '<br>';
|
||||
die();
|
||||
|
||||
//throw $th;
|
||||
}
|
||||
|
||||
$this->data_directory = 'raw';
|
||||
}
|
||||
|
||||
function _exec($qery, $argtypes, ...$args) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue