diff options
| author | Damien Regad <dregad@mantisbt.org> | 2024-08-28 09:31:09 +0200 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2024-08-28 09:35:10 +0200 |
| commit | 2bc630b08fa238eae697dd1fdbf89b6506e816be (patch) | |
| tree | 358051ce3fb03dd77caeb950ce730882f9cdba6b | |
| parent | 6eccac80d807b9cf2810061a3e468e199b790d41 (diff) | |
| parent | 804e325c26548b34abed04b8d23b9de87705b3a7 (diff) | |
| download | adodb-2bc630b08fa238eae697dd1fdbf89b6506e816be.tar.gz adodb-2bc630b08fa238eae697dd1fdbf89b6506e816be.tar.bz2 adodb-2bc630b08fa238eae697dd1fdbf89b6506e816be.zip | |
db2: fix connections using *LOCAL on IBM i series
Fixes:
- Support blank username and password for *LOCAL connections (#1031)
- Driver confuses schema name for database name (#1032)
PR https://github.com/ADOdb/ADOdb/pull/1034
| -rw-r--r-- | drivers/adodb-db2.inc.php | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/drivers/adodb-db2.inc.php b/drivers/adodb-db2.inc.php index 7c773849..60cd093a 100644 --- a/drivers/adodb-db2.inc.php +++ b/drivers/adodb-db2.inc.php @@ -109,10 +109,12 @@ class ADODB_db2 extends ADOConnection { return null; } - $connectionParameters = $this->unpackParameters($argDSN, - $argUsername, - $argPassword, - $argDatabasename); + $connectionParameters = $this->unpackParameters( + $argDSN, + $argUsername, + $argPassword, + $argDatabasename + ); if ($connectionParameters == null) { @@ -129,7 +131,12 @@ class ADODB_db2 extends ADOConnection { $useCataloguedConnection = $connectionParameters['catalogue']; if ($this->debug){ - if ($useCataloguedConnection){ + if (strcmp($argDSN,'*LOCAL') == 0) + { + $connectMessage = '*LOCAL connection'; + } + else if ($useCataloguedConnection) + { $connectMessage = "Catalogued connection using parameters: "; $connectMessage .= "DB=$argDatabasename / "; $connectMessage .= "UID=$argUsername / "; @@ -141,6 +148,7 @@ class ADODB_db2 extends ADOConnection { } ADOConnection::outp($connectMessage); } + /* * This needs to be set before the connect(). */ @@ -164,14 +172,17 @@ class ADODB_db2 extends ADOConnection { } if ($useCataloguedConnection) + { $this->_connectionID = $db2Function($argDatabasename, $argUsername, $argPassword, $db2Options); + } else + $this->_connectionID = $db2Function($argDSN, - null, - null, + '', + '', $db2Options); @@ -180,6 +191,9 @@ class ADODB_db2 extends ADOConnection { if ($this->_connectionID && $this->connectStmt) $this->execute($this->connectStmt); + if ($this->_connectionID && $argDatabasename) + $this->execute("SET SCHEMA=$argDatabasename"); + return $this->_connectionID != false; } @@ -198,12 +212,25 @@ class ADODB_db2 extends ADOConnection { { - $connectionParameters = array('dsn'=>'', - 'uid'=>'', - 'pwd'=>'', - 'database'=>'', - 'catalogue'=>true - ); + $connectionParameters = array( + 'dsn'=>'', + 'uid'=>'', + 'pwd'=>'', + 'database'=>'', + 'catalogue'=>true + ); + + /* + * Shortcut for *LOCAL + */ + if (strcmp($argDSN,'*LOCAL') == 0) + { + $connectionParameters['dsn'] = $argDSN; + $connectionParameters['database'] = $argDatabasename; + $connectionParameters['catalogue'] = false; + + return $connectionParameters; + } /* * Uou can either connect to a catalogued connection |
