diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2011-03-10 05:25:36 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-03-10 05:25:36 -0500 |
commit | 31eb45897a316bac2e56658866e11f04b06ee724 (patch) | |
tree | 9ffb34b08f8f15dd67d52bbdece6afcf86f4e2a1 /phpBB/includes/db/postgres.php | |
parent | 062c951d3398e3fa2d0b930d84db56ad9bc6de1f (diff) | |
parent | aa8f4000d30a3f89cb876eb14e3b7522c68f90f0 (diff) | |
download | forums-31eb45897a316bac2e56658866e11f04b06ee724.tar forums-31eb45897a316bac2e56658866e11f04b06ee724.tar.gz forums-31eb45897a316bac2e56658866e11f04b06ee724.tar.bz2 forums-31eb45897a316bac2e56658866e11f04b06ee724.tar.xz forums-31eb45897a316bac2e56658866e11f04b06ee724.zip |
Merge branch 'develop-olympus' into develop
* develop-olympus:
[ticket/10057] Fixes for a bunch of small problems.
[ticket/10035] ACP template edit feature allows to read any files on webserver.
[ticket/10057] Handle the case of missing interbase extension better.
[ticket/10057] Fixed wrong usage of sql_error again, in firebird.
[ticket/10057] Fixed usage of sql_error again.
[ticket/10057] Condition file/line display on DEBUG_EXTRA or IN_INSTALL.
[ticket/10057] Fixed wrong usage of sql_error in postgres dbal.
[ticket/10057] Skip ibase_service_attach if firebird connection failed.
[ticket/10057] Check for interbase function existence.
[ticket/10057] Split statements in firebird dbal for readability.
[ticket/10057] Include error collector class file in postgres dbal.
[ticket/10057] Moved error collector class into its own file.
[ticket/10057] Use a class for error collection.
[ticket/10057] More informative error messages in postgres dbal.
[ticket/10057] No negative array indexing.
[ticket/10057] Report postgres db connection errors.
Diffstat (limited to 'phpBB/includes/db/postgres.php')
-rw-r--r-- | phpBB/includes/db/postgres.php | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index 424ce12245..959d8df139 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -18,6 +18,11 @@ if (!defined('IN_PHPBB')) include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); +if (!class_exists('phpbb_error_collector')) +{ + include($phpbb_root_path . 'includes/error_collector.' . $phpEx); +} + /** * PostgreSQL Database Abstraction Layer * Minimum Requirement is Version 7.3+ @@ -26,6 +31,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); class dbal_postgres extends dbal { var $last_query_text = ''; + var $connect_error = ''; /** * Connect to server @@ -81,13 +87,29 @@ class dbal_postgres extends dbal if ($this->persistency) { + if (!function_exists('pg_pconnect')) + { + $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?'; + return $this->sql_error(''); + } + $collector = new phpbb_error_collector; + $collector->install(); $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW); } else { + if (!function_exists('pg_connect')) + { + $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?'; + return $this->sql_error(''); + } + $collector = new phpbb_error_collector; + $collector->install(); $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW); } + $collector->uninstall(); + if ($this->db_connect_id) { if (version_compare($this->sql_server_info(true), '8.2', '>=')) @@ -102,6 +124,7 @@ class dbal_postgres extends dbal return $this->db_connect_id; } + $this->connect_error = $collector->format_errors(); return $this->sql_error(''); } @@ -387,8 +410,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' => '' ); } |