diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2011-05-08 03:21:19 -0400 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-05-08 03:21:19 -0400 |
commit | ab44fe5e394fe7b69c57266e2934200a3ee9bbc5 (patch) | |
tree | e6021c19fa15800787b1a7459fb8ad40cf2d8391 /phpBB/includes/db/postgres.php | |
parent | 9c6660a2253149baff0094b943823de6758b35a6 (diff) | |
parent | c0336988155736583c6fc4398980bd2a4e4036b6 (diff) | |
download | forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.gz forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.bz2 forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.tar.xz forums-ab44fe5e394fe7b69c57266e2934200a3ee9bbc5.zip |
Merge branch 'develop' into feature/prune-users
* develop: (170 commits)
[ticket/10145] Always recompile all templates when DEBUG_EXTRA is defined.
[feature/attachment-management-no-reassignment] Handle privacy and some more.
[ticket/10148] Turn TEMPLATE_BITFIELD into an instance variable.
[ticket/10147] Corrected a typo in includes/functions_template.php.
[ticket/10141] Save a hash lookup when value is not in cache.
[ticket/10143] Added tests for storing a previously deleted value in db cache.
[ticket/10105] Update AIM express link.
[ticket/10105] Update AIM application download link.
[ticket/10137] Remove unintended space at end of PHP_URL_FOPEN_SUPPORT_EXPLAIN.
[ticket/10141] Split double-assignment into conditional and unconditional part.
[ticket/10141] Use a cache in $auth->_fill_acl() for better performance.
[ticket/9961] Create log entries when users are activated.
[ticket/10139] Make signatures of set_atomic() consistent by using $new_value.
[ticket/10139] Rename $cache to $use_cache to avoid confusion with cache object
[ticket/10006] Remove unneeded if statements
[ticket/10006] Remove return values
[ticket/10006] More testing
[ticket/10006] Tweak the tests a bit
[ticket/10006] Add phpbb_config::delete
[ticket/7941] Added @return to generate_board_url docstring.
...
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' => '' ); } |