Fix: property must be set if success
This commit is contained in:
parent
c39dadea14
commit
501dccabc2
@ -347,40 +347,46 @@ class DoliDb
|
|||||||
{
|
{
|
||||||
// use pg_connect() instead of pg_pconnect():
|
// use pg_connect() instead of pg_pconnect():
|
||||||
// To us persistent connection because this one cost 1ms, non persistent cost 30ms
|
// To us persistent connection because this one cost 1ms, non persistent cost 30ms
|
||||||
|
|
||||||
$this->db = false;
|
$this->db = false;
|
||||||
|
|
||||||
// connections parameters must be protected (only \ and ' according to pg_connect() manual)
|
// connections parameters must be protected (only \ and ' according to pg_connect() manual)
|
||||||
$host = str_replace(array("\\", "'"), array("\\\\", "\\'"), $host);
|
$host = str_replace(array("\\", "'"), array("\\\\", "\\'"), $host);
|
||||||
$login = str_replace(array("\\", "'"), array("\\\\", "\\'"), $login);
|
$login = str_replace(array("\\", "'"), array("\\\\", "\\'"), $login);
|
||||||
$passwd = str_replace(array("\\", "'"), array("\\\\", "\\'"), $passwd);
|
$passwd = str_replace(array("\\", "'"), array("\\\\", "\\'"), $passwd);
|
||||||
$name = str_replace(array("\\", "'"), array("\\\\", "\\'"), $name);
|
$name = str_replace(array("\\", "'"), array("\\\\", "\\'"), $name);
|
||||||
$port = str_replace(array("\\", "'"), array("\\\\", "\\'"), $port);
|
$port = str_replace(array("\\", "'"), array("\\\\", "\\'"), $port);
|
||||||
|
|
||||||
//if (! $name) $name="postgres";
|
//if (! $name) $name="postgres";
|
||||||
|
|
||||||
// try first Unix domain socket (local)
|
// try first Unix domain socket (local)
|
||||||
if (! $host || $host == "" || $host == "localhost")
|
if (! $host || $host == "" || $host == "localhost")
|
||||||
{
|
{
|
||||||
$con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'";
|
$con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'";
|
||||||
$this->db = pg_connect($con_string);
|
$this->db = pg_connect($con_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if local connection failed or not requested, use TCP/IP
|
// if local connection failed or not requested, use TCP/IP
|
||||||
if (! $this->db)
|
if (! $this->db)
|
||||||
{
|
{
|
||||||
if (! $host) $host = "localhost";
|
if (! $host) $host = "localhost";
|
||||||
if (! $port) $port = 5432;
|
if (! $port) $port = 5432;
|
||||||
|
|
||||||
$con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'";
|
$con_string = "host='".$host."' port='".$port."' dbname='".$name."' user='".$login."' password='".$passwd."'";
|
||||||
$this->db = pg_connect($con_string);
|
$this->db = pg_connect($con_string);
|
||||||
|
|
||||||
|
if ($this->db)
|
||||||
|
{
|
||||||
|
$this->database_name = $name;
|
||||||
|
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->database_name = $name;
|
$this->database_name = $name;
|
||||||
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
|
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db;
|
return $this->db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user