[BUGFIX] ADOdb: mssqlnative driver is not properly initialized
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / Documentation / typo3-adodb.diff
index b41b529..520c47a 100644 (file)
@@ -210,6 +210,52 @@ diff --git a/drivers/adodb-mssqlnative.inc.php b/drivers/adodb-mssqlnative.inc.p
 index b10d555..21cfc69 100644
 --- a/drivers/adodb-mssqlnative.inc.php
 +++ b/drivers/adodb-mssqlnative.inc.php
+@@ -209,10 +209,10 @@ class ADODB_mssqlnative extends ADOConnection {
+               switch($this->mssql_version){
+               case 9:
+               case 10:
+-                      return $this->GenID2008();
++                      return $this->GenID2008($seq, $start);
+                       break;
+               case 11:
+-                      return $this->GenID2012();
++                      return $this->GenID2012($seq, $start);
+                       break;
+               }
+       }
+@@ -225,10 +225,10 @@ class ADODB_mssqlnative extends ADOConnection {
+               switch($this->mssql_version){
+               case 9:
+               case 10:
+-                      return $this->CreateSequence2008();
++                      return $this->CreateSequence2008($seq, $start);
+                       break;
+               case 11:
+-                      return $this->CreateSequence2012();
++                      return $this->CreateSequence2012($seq, $start);
+                       break;
+               }
+@@ -287,7 +287,7 @@ class ADODB_mssqlnative extends ADOConnection {
+               }
+               $num = $this->GetOne("select id from $seq");
+               sqlsrv_commit($this->_connectionID);
+-              return true;
++              return $num;
+       }
+       /**
+        * Only available to Server 2012 and up
+
+@@ -311,7 +311,7 @@ class ADODB_mssqlnative extends ADOConnection {
+               }
+               if (!is_array($this->sequences)
+               || is_array($this->sequences) && !in_array($seq,$this->sequences)){
+-                      $this->CreateSequence2012($seq='adodbseq',$start=1);
++                      $this->CreateSequence2012($seq, $start);
+               }
+               $num = $this->GetOne("SELECT NEXT VALUE FOR $seq");
+
 @@ -459,7 +459,7 @@ class ADODB_mssqlnative extends ADOConnection {
                                $this->_errorMsg .= "Message: ".$arrError[ 'message']."\n";
                        }
@@ -219,3 +265,35 @@ index b10d555..21cfc69 100644
                }
                return $this->_errorMsg;
        }
+
+@@ -476,10 +476,26 @@ class ADODB_mssqlnative extends ADOConnection {
+       function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+       {
+               if (!function_exists('sqlsrv_connect')) return null;
++              // Port is always given as part of $argHostname but
++              // 1) should only be set if using an IP/hostname and not a named instance
++              // 2) must use a comma instead of a colon
++              list ($hostname, $port) = explode(':', $argHostname, 2);
++              if (strpos($hostname, '\\') === false) {
++                      $argHostname = $hostname . ',' . $port;
++              } else {
++                      $argHostname = $hostname;
++              }
+               $connectionInfo = $this->connectionInfo;
+-              $connectionInfo["Database"]=$argDatabasename;
+-              $connectionInfo["UID"]=$argUsername;
+-              $connectionInfo["PWD"]=$argPassword;
++              $connectionInfo['Database'] = $argDatabasename;
++              if (!empty($argUsername)) {
++                      $connectionInfo['UID'] = $argUsername;
++              }
++              if (!empty($argPassword)) {
++                      $connectionInfo['PWD'] = $argPassword;
++              }
++              if (!empty($this->charSet)) {
++                      $connectionInfo['CharacterSet'] = $this->charSet;
++              }
+               if ($this->debug) error_log("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
+               //if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID));
+               if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
+