mirror of
https://github.com/vrana/adminer.git
synced 2025-08-14 18:44:02 +02:00
Use postgres instead of template1 as default database (bug #3491125)
This commit is contained in:
@@ -21,11 +21,11 @@ if (isset($_GET["pgsql"])) {
|
|||||||
$db = $adminer->database();
|
$db = $adminer->database();
|
||||||
set_error_handler(array($this, '_error'));
|
set_error_handler(array($this, '_error'));
|
||||||
$this->_string = "host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' user='" . addcslashes($username, "'\\") . "' password='" . addcslashes($password, "'\\") . "'";
|
$this->_string = "host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' user='" . addcslashes($username, "'\\") . "' password='" . addcslashes($password, "'\\") . "'";
|
||||||
$this->_link = @pg_connect("$this->_string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "template1") . "'", PGSQL_CONNECT_FORCE_NEW);
|
$this->_link = @pg_connect("$this->_string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'", PGSQL_CONNECT_FORCE_NEW);
|
||||||
if (!$this->_link && $db != "") {
|
if (!$this->_link && $db != "") {
|
||||||
// try to connect directly with database for performance
|
// try to connect directly with database for performance
|
||||||
$this->_database = false;
|
$this->_database = false;
|
||||||
$this->_link = @pg_connect("$this->_string dbname='template1'", PGSQL_CONNECT_FORCE_NEW);
|
$this->_link = @pg_connect("$this->_string dbname='postgres'", PGSQL_CONNECT_FORCE_NEW);
|
||||||
}
|
}
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if ($this->_link) {
|
if ($this->_link) {
|
||||||
@@ -53,7 +53,7 @@ if (isset($_GET["pgsql"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
$this->_link = @pg_connect("$this->_string dbname='template1'");
|
$this->_link = @pg_connect("$this->_string dbname='postgres'");
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query, $unbuffered = false) {
|
function query($query, $unbuffered = false) {
|
||||||
@@ -132,7 +132,7 @@ if (isset($_GET["pgsql"])) {
|
|||||||
global $adminer;
|
global $adminer;
|
||||||
$db = $adminer->database();
|
$db = $adminer->database();
|
||||||
$string = "pgsql:host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' options='-c client_encoding=utf8'";
|
$string = "pgsql:host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' options='-c client_encoding=utf8'";
|
||||||
$this->dsn("$string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "template1") . "'", $username, $password);
|
$this->dsn("$string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'", $username, $password);
|
||||||
//! connect without DB in case of an error
|
//! connect without DB in case of an error
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user