m-h-c-t / mh-hunt-helper

Tool to help collect data, estimate attraction, catch, and drop rates for a popular game.
https://www.mhct.win
MIT License
7 stars 14 forks source link

More confgurable database connections #124

Open AardWolf opened 3 years ago

AardWolf commented 3 years ago

When I'm working locally with multiple databases in docker I've been tying them to specific ports so I don't have to worry about starting them in the right order and can still use dbeaver to connect. But then I have to fiddle with a bunch of php files that want to connect to mysql on the default port.

So, in config.php if we can somehow specify the full connection string then we would be able to override the port and even the database flavor if we wanted to mess with something that supports OLAP queries (with WINDOW and similar).

logicalup commented 3 years ago

config.php is not git committed obviously, so i suggest we add $db_type variable in the config.php.sample and then do an if statement in the configs.php.sample to check


if ($db_type = 'mysql') {
$pdo = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} else if ($db_type = 'db2') {
// whatever we need for db2 here, you guys know better what
$pdo = new PDO("db2:host=$servername;dbname=$dbname;charset=utf8", $username, $password);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}