mysql custom port in config
This commit is contained in:
parent
6dacf524bc
commit
fb50e282d9
2 changed files with 12 additions and 7 deletions
|
@ -23,6 +23,7 @@ class DB
|
|||
// Initialise PDO object
|
||||
private final function __construct(){
|
||||
$host = Config::get_safe('mysql_host', false);
|
||||
$port = Config::get_safe('mysql_port', false);
|
||||
$socket = Config::get_safe('mysql_socket', false);
|
||||
|
||||
if($socket === false && $host === false){
|
||||
|
@ -33,11 +34,15 @@ class DB
|
|||
try {
|
||||
$this->_PDO = new \PDO(
|
||||
// Server
|
||||
'mysql:'.($socket !== false ? 'unix_socket='.$socket : 'host='.$host).';'.
|
||||
'mysql:'.
|
||||
($socket !== false
|
||||
? 'unix_socket='.$socket
|
||||
: 'host='.$host.($port !== false ? ';port='.$port : '')
|
||||
).
|
||||
// DB
|
||||
'dbname='.Config::get('db_name').';'.
|
||||
';dbname='.Config::get('db_name').
|
||||
// Charset
|
||||
'charset=utf8',
|
||||
';charset=utf8',
|
||||
// Username
|
||||
Config::get('mysql_user'),
|
||||
// Password
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[database]
|
||||
;mysql_socket = /tmp/mariadb55.sock
|
||||
;mysql_host = localhost
|
||||
;mysql_user = root
|
||||
;mysql_pass =
|
||||
;db_name = root
|
||||
mysql_host = localhost
|
||||
mysql_user = root
|
||||
mysql_pass = root
|
||||
db_name = blog
|
||||
|
||||
[profile]
|
||||
title = Blog
|
||||
|
|
Loading…
Add table
Reference in a new issue