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() {
|
function serendipity_db_connect() {
|
||||||
global $serendipity;
|
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(
|
$serendipity['dbConn'] = new PDO(
|
||||||
sprintf(
|
sprintf(
|
||||||
'pgsql:%sdbname=%s',
|
'pgsql:%sdbname=%s',
|
||||||
strlen($serendipity['dbHost']) ? ('host=' . $serendipity['dbHost'] . ';') : '',
|
"$host$port",
|
||||||
$serendipity['dbName']
|
$serendipity['dbName']
|
||||||
),
|
),
|
||||||
$serendipity['dbUser'],
|
$serendipity['dbUser'],
|
||||||
|
@ -53,10 +53,22 @@ function serendipity_db_connect() {
|
|||||||
$function = 'pg_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(
|
$serendipity['dbConn'] = $function(
|
||||||
sprintf(
|
sprintf(
|
||||||
'%sdbname=%s user=%s password=%s',
|
'%sdbname=%s user=%s password=%s',
|
||||||
strlen($serendipity['dbHost']) ? ('host=' . $serendipity['dbHost'] . ' ') : '',
|
"$host$port",
|
||||||
$serendipity['dbName'],
|
$serendipity['dbName'],
|
||||||
$serendipity['dbUser'],
|
$serendipity['dbUser'],
|
||||||
$serendipity['dbPass']
|
$serendipity['dbPass']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user