mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
MDL-17020 dml: native pgsql driver - socket and persistent connection support
This commit is contained in:
parent
6cc9771844
commit
dd2ce45907
@ -86,8 +86,21 @@ class pgsql_native_moodle_database extends moodle_database {
|
||||
|
||||
$this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
|
||||
|
||||
//TODO: handle both port and socket connection
|
||||
$this->pgsql = pg_connect("host='{$this->dbhost}' user='{$this->dbuser}' password='{$this->dbpass}' dbname='{$this->dbname}'");
|
||||
$pass = addcslashes($this->dbpass, "'\\");
|
||||
|
||||
// Unix socket connections should have lower overhead
|
||||
if (empty($this->dboptions['forcetcp']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1')) {
|
||||
$connection = "user='$this->dbuser' password='$pass' dbname='$this->dbname'";
|
||||
} else {
|
||||
$connection = "host='$this->dbhost' user='$this->dbuser' password='$pass' dbname='$this->dbname'";
|
||||
}
|
||||
|
||||
if (empty($this->dboptions['dbpersit'])) {
|
||||
$this->pgsql = pg_connect($connection, PGSQL_CONNECT_FORCE_NEW);
|
||||
} else {
|
||||
$this->pgsql = pg_pconnect($connection, PGSQL_CONNECT_FORCE_NEW);
|
||||
}
|
||||
|
||||
$status = pg_connection_status($this->pgsql);
|
||||
if ($status === PGSQL_CONNECTION_BAD) {
|
||||
$this->pgsql = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user