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/firebird.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/firebird.php')
-rw-r--r-- | phpBB/includes/db/firebird.php | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 69476f79f8..8868d4e317 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -28,6 +28,7 @@ class dbal_firebird extends dbal var $last_query_text = ''; var $service_handle = false; var $affected_rows = 0; + var $connect_error = ''; /** * Connect to server @@ -53,9 +54,35 @@ class dbal_firebird extends dbal $use_database = $this->server . ':' . $this->dbname; } - $this->db_connect_id = ($this->persistency) ? @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3); + if ($this->persistency) + { + if (!function_exists('ibase_pconnect')) + { + $this->connect_error = 'ibase_pconnect function does not exist, is interbase extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ibase_pconnect($use_database, $this->user, $sqlpassword, false, false, 3); + } + else + { + if (!function_exists('ibase_connect')) + { + $this->connect_error = 'ibase_connect function does not exist, is interbase extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ibase_connect($use_database, $this->user, $sqlpassword, false, false, 3); + } - $this->service_handle = (function_exists('ibase_service_attach') && $this->server) ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false; + // Do not call ibase_service_attach if connection failed, + // otherwise error message from ibase_(p)connect call will be clobbered. + if ($this->db_connect_id && function_exists('ibase_service_attach') && $this->server) + { + $this->service_handle = @ibase_service_attach($this->server, $this->user, $sqlpassword); + } + else + { + $this->service_handle = false; + } return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); } @@ -487,8 +514,24 @@ class dbal_firebird extends dbal */ function _sql_error() { + // Need special handling here because ibase_errmsg returns + // connection errors, however if the interbase extension + // is not installed then ibase_errmsg does not exist and + // we cannot call it. + if (function_exists('ibase_errmsg')) + { + $msg = @ibase_errmsg(); + if (!$msg) + { + $msg = $this->connect_error; + } + } + else + { + $msg = $this->connect_error; + } return array( - 'message' => @ibase_errmsg(), + 'message' => $msg, 'code' => (@function_exists('ibase_errcode') ? @ibase_errcode() : '') ); } |