diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2011-03-06 23:17:01 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-03-06 23:17:01 -0500 |
commit | 98388b29212cf94c443e0b4f626508efc937715f (patch) | |
tree | 155e8140435187b1b7cdb4e7d81ddd31734b5af4 /phpBB/includes/db/postgres.php | |
parent | edc1deaa3afcadab82d404e705e162a9f3fa26c5 (diff) | |
download | forums-98388b29212cf94c443e0b4f626508efc937715f.tar forums-98388b29212cf94c443e0b4f626508efc937715f.tar.gz forums-98388b29212cf94c443e0b4f626508efc937715f.tar.bz2 forums-98388b29212cf94c443e0b4f626508efc937715f.tar.xz forums-98388b29212cf94c443e0b4f626508efc937715f.zip |
[ticket/10057] Fixed wrong usage of sql_error in postgres dbal.
pg_last_error does not work if no connection was ever established.
Therefore we must keep track of connection errors in postgres
dbal ourselves.
PHPBB3-10057
Diffstat (limited to 'phpBB/includes/db/postgres.php')
-rw-r--r-- | phpBB/includes/db/postgres.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index d703f5b567..78b6a75750 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -31,6 +31,7 @@ if (!class_exists('phpbb_error_collector')) class dbal_postgres extends dbal { var $last_query_text = ''; + var $connect_error = ''; /** * Connect to server @@ -121,8 +122,8 @@ class dbal_postgres extends dbal return $this->db_connect_id; } - $errors = $collector->format_errors(); - return $this->sql_error($errors); + $this->connect_error = $collector->format_errors(); + return $this->sql_error(''); } /** @@ -391,8 +392,19 @@ class dbal_postgres extends dbal */ function _sql_error() { + // pg_last_error only works when there is an established connection. + // Connection errors have to be tracked by us manually. + if ($this->db_connect_id) + { + $message = @pg_last_error($this->db_connect_id); + } + else + { + $message = $this->connect_error; + } + return array( - 'message' => (!$this->db_connect_id) ? @pg_last_error() : @pg_last_error($this->db_connect_id), + 'message' => $message, 'code' => '' ); } |