[BUGFIX] ADOdb: mssqlnative driver is not properly initialized
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / Documentation / typo3-adodb.diff
index b1ad640..520c47a 100644 (file)
@@ -193,16 +193,107 @@ index 81fb016..5ff76b9 100644
 @@ -67,13 +67,13 @@ class ADODB2_sqlite extends ADODB_DataDict {
                return $suffix;
        }
+
 -      function AlterColumnSQL($tabname, $flds)
 +      function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
        {
                if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
                return array();
        }
+
 -      function DropColumnSQL($tabname, $flds)
 +      function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
        {
                if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
                return array();
+diff --git a/drivers/adodb-mssqlnative.inc.php b/drivers/adodb-mssqlnative.inc.php
+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";
+                       }
+               } else {
+-                      $this->_errorMsg = "No errors found";
++                      $this->_errorMsg = '';
+               }
+               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))) {
+