diff options
| -rw-r--r-- | drivers/adodb-ads.inc.php | 45 | ||||
| -rw-r--r-- | drivers/adodb-db2.inc.php | 30 | ||||
| -rw-r--r-- | drivers/adodb-odbc.inc.php | 32 | ||||
| -rw-r--r-- | drivers/adodb-odbc_oracle.inc.php | 13 | ||||
| -rw-r--r-- | drivers/adodb-odbtp.inc.php | 8 | ||||
| -rw-r--r-- | drivers/adodb-sybase.inc.php | 7 |
6 files changed, 65 insertions, 70 deletions
diff --git a/drivers/adodb-ads.inc.php b/drivers/adodb-ads.inc.php index d59df663..c678c9de 100644 --- a/drivers/adodb-ads.inc.php +++ b/drivers/adodb-ads.inc.php @@ -75,17 +75,16 @@ class ADODB_ads extends ADOConnection { // returns true or false function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) { - global $php_errormsg; - if (!function_exists('ads_connect')) return null; if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') { ADOConnection::outp("For Advantage Connect(), $argDatabasename is not used. Place dsn in 1st parameter."); } - if (isset($php_errormsg)) $php_errormsg = ''; + error_clear_last(); if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword,$this->curmode); - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; if (isset($this->connectStmt)) $this->Execute($this->connectStmt); return $this->_connectionID != false; @@ -94,12 +93,10 @@ class ADODB_ads extends ADOConnection { // returns true or false function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { - global $php_errormsg; if (!function_exists('ads_connect')) return null; - if (isset($php_errormsg)) $php_errormsg = ''; - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + error_clear_last(); if ($this->debug && $argDatabasename) { ADOConnection::outp("For PConnect(), $argDatabasename is not used. Place dsn in 1st parameter."); } @@ -107,7 +104,8 @@ class ADODB_ads extends ADOConnection { if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = ads_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; if ($this->_connectionID && $this->autoRollback) @ads_rollback($this->_connectionID); if (isset($this->connectStmt)) $this->Execute($this->connectStmt); @@ -519,8 +517,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od /* returns queryID or false */ function _query($sql,$inputarr=false) { - GLOBAL $php_errormsg; - if (isset($php_errormsg)) $php_errormsg = ''; + error_clear_last(); $this->_error = ''; if ($inputarr) { @@ -530,7 +527,8 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od $stmtid = ads_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; } } @@ -563,8 +561,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od $this->_lastAffectedRows = 0; - if ($stmtid) - { + if ($stmtid) { if (@ads_num_fields($stmtid) == 0) { $this->_lastAffectedRows = ads_num_rows($stmtid); @@ -578,22 +575,21 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od } - if ($this->_haserrorfunctions) - { - + if ($this->_haserrorfunctions) { $this->_errorMsg = ''; $this->_errorCode = 0; + } else { + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; } - else - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - } - else - { + } else { if ($this->_haserrorfunctions) { $this->_errorMsg = ads_errormsg(); $this->_errorCode = ads_error(); - } else - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + } else { + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; + } } return $stmtid; @@ -614,7 +610,8 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od $sql = "UPDATE $table SET $column=? WHERE $where"; $stmtid = ads_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; } if (! ads_execute($stmtid,array($val),array(SQL_BINARY) )){ diff --git a/drivers/adodb-db2.inc.php b/drivers/adodb-db2.inc.php index 1312b70b..eacecd29 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); @@ -627,9 +618,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 +628,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 +666,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; } diff --git a/drivers/adodb-odbc.inc.php b/drivers/adodb-odbc.inc.php index 56d6c307..4ab7a031 100644 --- a/drivers/adodb-odbc.inc.php +++ b/drivers/adodb-odbc.inc.php @@ -50,8 +50,6 @@ class ADODB_odbc extends ADOConnection { // returns true or false function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) { - global $php_errormsg; - if (!function_exists('odbc_connect')) return null; if (!empty($argDatabasename) && stristr($argDSN, 'Database=') === false) { @@ -61,10 +59,11 @@ class ADODB_odbc extends ADOConnection { $argDSN .= 'Database='.$argDatabasename; } - if (isset($php_errormsg)) $php_errormsg = ''; + error_clear_last(); if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode); - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; if (isset($this->connectStmt)) $this->Execute($this->connectStmt); return $this->_connectionID != false; @@ -73,12 +72,10 @@ class ADODB_odbc extends ADOConnection { // returns true or false function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { - global $php_errormsg; if (!function_exists('odbc_connect')) return null; - if (isset($php_errormsg)) $php_errormsg = ''; - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + error_clear_last(); if ($this->debug && $argDatabasename) { ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter."); } @@ -86,7 +83,8 @@ class ADODB_odbc extends ADOConnection { if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID); if (isset($this->connectStmt)) $this->Execute($this->connectStmt); @@ -503,8 +501,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od /* returns queryID or false */ function _query($sql,$inputarr=false) { - GLOBAL $php_errormsg; - if (isset($php_errormsg)) $php_errormsg = ''; + error_clear_last(); $this->_error = ''; if ($inputarr) { @@ -514,7 +511,8 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od $stmtid = odbc_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; } } @@ -555,14 +553,18 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od 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 = odbc_errormsg(); $this->_errorCode = odbc_error(); - } else - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + } else { + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; + } } return $stmtid; } diff --git a/drivers/adodb-odbc_oracle.inc.php b/drivers/adodb-odbc_oracle.inc.php index 91416d21..ded5fcc9 100644 --- a/drivers/adodb-odbc_oracle.inc.php +++ b/drivers/adodb-odbc_oracle.inc.php @@ -76,11 +76,10 @@ class ADODB_odbc_oracle extends ADODB_odbc { // returns true or false function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) { - global $php_errormsg; - - $php_errormsg = ''; + error_clear_last(); $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); - $this->_errorMsg = $php_errormsg; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); @@ -89,10 +88,10 @@ class ADODB_odbc_oracle extends ADODB_odbc { // returns true or false function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) { - global $php_errormsg; - $php_errormsg = ''; + error_clear_last(); $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); - $this->_errorMsg = $php_errormsg; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); diff --git a/drivers/adodb-odbtp.inc.php b/drivers/adodb-odbtp.inc.php index 7fd3689c..89c58a80 100644 --- a/drivers/adodb-odbtp.inc.php +++ b/drivers/adodb-odbtp.inc.php @@ -609,9 +609,8 @@ class ADODB_odbtp extends ADOConnection{ function _query($sql,$inputarr=false) { - global $php_errormsg; - - $this->_errorMsg = false; + error_clear_last(); + $this->_errorMsg = false; $this->_errorCode = false; if ($inputarr) { @@ -620,7 +619,8 @@ class ADODB_odbtp extends ADOConnection{ } else { $stmtid = @odbtp_prepare($sql,$this->_connectionID); if ($stmtid == false) { - $this->_errorMsg = $php_errormsg; + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : ''; return false; } } diff --git a/drivers/adodb-sybase.inc.php b/drivers/adodb-sybase.inc.php index 2f77885f..4e4dd53d 100644 --- a/drivers/adodb-sybase.inc.php +++ b/drivers/adodb-sybase.inc.php @@ -117,8 +117,11 @@ class ADODB_sybase extends ADOConnection { if ($this->_logsql) return $this->_errorMsg; if (function_exists('sybase_get_last_message')) $this->_errorMsg = sybase_get_last_message(); - else - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : 'SYBASE error messages not supported on this platform'; + else { + $err = error_get_last(); + $this->_errorMsg = $err ? $err['message'] : 'SYBASE error messages not supported on this platform'; + } + return $this->_errorMsg; } |
