Support port config for postgres db connection
Upport from master
This commit is contained in:
parent
a94b4a618a
commit
f574fe1a87
@ -49,10 +49,21 @@ function serendipity_db_in_sql($col, &$search_ids, $type = ' OR ') {
|
||||
function serendipity_db_connect() {
|
||||
global $serendipity;
|
||||
|
||||
$host = port = '';
|
||||
if (strlen($serendipity['dbHost'])) {
|
||||
if (false !== strstr($serendipity['dbHost'], ':')) {
|
||||
$tmp = explode(':', $serendipity['dbHost']);
|
||||
$host = "host={$tmp[0]};";
|
||||
$port = "port={$tmp[1]};";
|
||||
} else {
|
||||
$host = "host={$serendipity['dbHost']};";
|
||||
}
|
||||
}
|
||||
|
||||
$serendipity['dbConn'] = new PDO(
|
||||
sprintf(
|
||||
'pgsql:%sdbname=%s',
|
||||
strlen($serendipity['dbHost']) ? ('host=' . $serendipity['dbHost'] . ';') : '',
|
||||
"$host$port",
|
||||
$serendipity['dbName']
|
||||
),
|
||||
$serendipity['dbUser'],
|
||||
|
@ -53,10 +53,22 @@ function serendipity_db_connect() {
|
||||
$function = 'pg_connect';
|
||||
}
|
||||
|
||||
$host = port = '';
|
||||
if (strlen($serendipity['dbHost'])) {
|
||||
if (false !== strstr($serendipity['dbHost'], ':')) {
|
||||
$tmp = explode(':', $serendipity['dbHost']);
|
||||
$host = "host={$tmp[0]} ";
|
||||
$port = "port={$tmp[1]} ";
|
||||
} else {
|
||||
$host = "host={$serendipity['dbHost']} ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$serendipity['dbConn'] = $function(
|
||||
sprintf(
|
||||
'%sdbname=%s user=%s password=%s',
|
||||
strlen($serendipity['dbHost']) ? ('host=' . $serendipity['dbHost'] . ' ') : '',
|
||||
"$host$port",
|
||||
$serendipity['dbName'],
|
||||
$serendipity['dbUser'],
|
||||
$serendipity['dbPass']
|
||||
|
Loading…
x
Reference in New Issue
Block a user