Fix splitting of db info. #576
This commit is contained in:
parent
bd0b24b034
commit
4351d1242e
1 changed files with 3 additions and 3 deletions
|
|
@ -26,17 +26,17 @@ $dotenv->loadEnv(__DIR__.'/../../.env');
|
|||
|
||||
$db_info = $_ENV['DATABASE_URL'];
|
||||
|
||||
// sample format of db_info: mysql://db_user:db_password@127.0.0.1:3306/resq
|
||||
// sample format of db_info: mysql://db_user:db_password@127.0.0.1:3306/resq?charset=utf8
|
||||
// dsn for PDO needs to be: mysql:host=127.0.0.1:3306;dbname=resq;charset=UTF8
|
||||
|
||||
preg_match('/^mysql:\/\/(.*):(.*)@(.*):(.*)\/(.*)/', $db_info, $result);
|
||||
preg_match('/^mysql:\/\/(.*):(.*)@(.*):(.*)\/(.*)\?(.*)/', $db_info, $result);
|
||||
|
||||
$db_type = 'mysql:host=';
|
||||
$user = $result[1];
|
||||
$pass = $result[2];
|
||||
$ip_port = $result[3] . ':' . $result[4] . ';';
|
||||
$db_name = 'dbname=' . $result[5] . ';';
|
||||
$charset = 'charset=UTF8';
|
||||
$charset = $result[6];
|
||||
|
||||
$dsn = $db_type . $ip_port . $db_name . $charset;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue