summaryrefslogtreecommitdiff
path: root/drivers/adodb-db2.inc.php
diff options
context:
space:
mode:
authorDamien Regad <dregad@mantisbt.org>2018-03-30 18:47:26 +0200
committerDamien Regad <dregad@mantisbt.org>2018-03-30 18:47:26 +0200
commitbd898bf510431e2f8bce2469d188821e200af29f (patch)
treec0b49b1f62e2c396bdd91ea09116f03cf344f70b /drivers/adodb-db2.inc.php
parent62ebb04b157467f4e650ef0e7a02120a2b41c169 (diff)
parentd29c23f2264ec95c6d3851e0f51ce240b2f36b74 (diff)
downloadadodb-bd898bf510431e2f8bce2469d188821e200af29f.tar.gz
adodb-bd898bf510431e2f8bce2469d188821e200af29f.tar.bz2
adodb-bd898bf510431e2f8bce2469d188821e200af29f.zip
Merge branch 'hotfix/5.20'
I messed up the merge at c350c007ed585a4da4dc8c62ae7954cfe13b621f. Not sure what I did or how, but the changes from the hotfix branch got lost. Redoing the merge to fix the problem.
Diffstat (limited to 'drivers/adodb-db2.inc.php')
-rw-r--r--drivers/adodb-db2.inc.php33
1 files changed, 14 insertions, 19 deletions
diff --git a/drivers/adodb-db2.inc.php b/drivers/adodb-db2.inc.php
index be84ae49..d5b92665 100644
--- a/drivers/adodb-db2.inc.php
+++ b/drivers/adodb-db2.inc.php
@@ -71,8 +71,6 @@ class ADODB_db2 extends ADOConnection {
// returns true or false
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
- global $php_errormsg;
-
if (!function_exists('db2_connect')) {
ADOConnection::outp("Warning: The old ODBC based DB2 driver has been renamed 'odbc_db2'. This ADOdb driver calls PHP's native db2 extension which is not installed.");
return null;
@@ -90,7 +88,6 @@ class ADODB_db2 extends ADOConnection {
if (stripos($argDSN,'UID=') && stripos($argDSN,'PWD=')) $this->_connectionID = db2_connect($argDSN,null,null);
else $this->_connectionID = db2_connect($argDSN,$argUsername,$argPassword);
}
- if (isset($php_errormsg)) $php_errormsg = '';
// For db2_connect(), there is an optional 4th arg. If present, it must be
// an array of valid options. So far, we don't use them.
@@ -105,17 +102,12 @@ class ADODB_db2 extends ADOConnection {
// returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
- global $php_errormsg;
-
if (!function_exists('db2_connect')) return null;
// This needs to be set before the connect().
// Replaces the odbc_binmode() call that was in Execute()
ini_set('ibm_db2.binmode', $this->binmode);
- if (isset($php_errormsg)) $php_errormsg = '';
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
-
if ($argDatabasename && empty($argDSN)) {
if (stripos($argDatabasename,'UID=') && stripos($argDatabasename,'PWD=')) $this->_connectionID = db2_pconnect($argDatabasename,null,null);
@@ -125,7 +117,6 @@ class ADODB_db2 extends ADOConnection {
if (stripos($argDSN,'UID=') && stripos($argDSN,'PWD=')) $this->_connectionID = db2_pconnect($argDSN,null,null);
else $this->_connectionID = db2_pconnect($argDSN,$argUsername,$argPassword);
}
- if (isset($php_errormsg)) $php_errormsg = '';
$this->_errorMsg = @db2_conn_errormsg();
if ($this->_connectionID && $this->autoRollback) @db2_rollback($this->_connectionID);
@@ -243,7 +234,8 @@ class ADODB_db2 extends ADOConnection {
function SelectLimit($sql, $nrows = -1, $offset = -1, $inputArr = false, $secs2cache = 0)
{
- $nrows = (integer) $nrows;
+ $nrows = (int) $nrows;
+ $offset = (int) $offset;
if ($offset <= 0) {
// could also use " OPTIMIZE FOR $nrows ROWS "
if ($nrows >= 0) $sql .= " FETCH FIRST $nrows ROWS ONLY ";
@@ -627,9 +619,8 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
/* returns queryID or false */
function _query($sql,$inputarr=false)
{
- GLOBAL $php_errormsg;
- if (isset($php_errormsg)) $php_errormsg = '';
- $this->_error = '';
+ error_clear_last();
+ $this->_errorMsg = '';
if ($inputarr) {
if (is_array($sql)) {
@@ -638,7 +629,8 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
$stmtid = db2_prepare($this->_connectionID,$sql);
if ($stmtid == false) {
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ $err = error_get_last();
+ $this->_errorMsg = $err ? $err['message'] : '';
return false;
}
}
@@ -675,15 +667,18 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
if ($this->_haserrorfunctions) {
$this->_errorMsg = '';
$this->_errorCode = 0;
- } else
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ } else {
+ $err = error_get_last();
+ $this->_errorMsg = $err ? $err['message'] : '';
+ }
} else {
if ($this->_haserrorfunctions) {
$this->_errorMsg = db2_stmt_errormsg();
$this->_errorCode = db2_stmt_error();
- } else
- $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
-
+ } else {
+ $err = error_get_last();
+ $this->_errorMsg = $err ? $err['message'] : '';
+ }
}
return $stmtid;
}