"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/drivers/adodb-ado_mssql.inc.php Source File", "datetime" => "Sat Dec 2 19:22:25 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

adodb-ado_mssql.inc.php

00001 <?php
00002 /* 
00003 V4.90 8 June 2006  (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
00004   Released under both BSD license and Lesser GPL library license. 
00005   Whenever there is any discrepancy between the two licenses, 
00006   the BSD license will take precedence. 
00007 Set tabs to 4 for best viewing.
00008   
00009   Latest version is available at http://adodb.sourceforge.net
00010   
00011   Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client. 
00012   Works only on MS Windows.
00013   
00014   Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used. 
00015   Please check http://bugs.php.net/ for more info.
00016 */
00017 
00018 // security - hide paths
00019 if (!defined('ADODB_DIR')) die();
00020 
00021 if (!defined('_ADODB_ADO_LAYER')) {
00022         if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
00023         else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
00024 }
00025 
00026 
00027 class  ADODB_ado_mssql extends ADODB_ado {        
00028         var $databaseType = 'ado_mssql';
00029         var $hasTop = 'top';
00030         var $hasInsertID = true;
00031         var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
00032         var $sysTimeStamp = 'GetDate()';
00033         var $leftOuter = '*=';
00034         var $rightOuter = '=*';
00035         var $ansiOuter = true; // for mssql7 or later
00036         var $substr = "substring";
00037         var $length = 'len';
00038         
00039         //var $_inTransaction = 1; // always open recordsets, so no transaction problems.
00040         
00041         function ADODB_ado_mssql()
00042         {
00043                 $this->ADODB_ado();
00044         }
00045         
00046         function _insertid()
00047         {
00048                 return $this->GetOne('select @@identity');
00049         }
00050         
00051         function _affectedrows()
00052         {
00053                 return $this->GetOne('select @@rowcount');
00054         }
00055         
00056         function SetTransactionMode( $transaction_mode ) 
00057         {
00058                 $this->_transmode  = $transaction_mode;
00059                 if (empty($transaction_mode)) {
00060                         $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
00061                         return;
00062                 }
00063                 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
00064                 $this->Execute("SET TRANSACTION ".$transaction_mode);
00065         }
00066         
00067         function MetaColumns($table)
00068         {
00069         $table = strtoupper($table);
00070         $arr= array();
00071         $dbc = $this->_connectionID;
00072         
00073         $osoptions = array();
00074         $osoptions[0] = null;
00075         $osoptions[1] = null;
00076         $osoptions[2] = $table;
00077         $osoptions[3] = null;
00078         
00079         $adors=@$dbc->OpenSchema(4, $osoptions);//tables
00080 
00081         if ($adors){
00082                 while (!$adors->EOF){
00083                         $fld = new ADOFieldObject();
00084                         $c = $adors->Fields(3);
00085                         $fld->name = $c->Value;
00086                         $fld->type = 'CHAR'; // cannot discover type in ADO!
00087                         $fld->max_length = -1;
00088                         $arr[strtoupper($fld->name)]=$fld;
00089         
00090                         $adors->MoveNext();
00091                 }
00092                 $adors->Close();
00093         }
00094         $false = false;
00095                 return empty($arr) ? $false : $arr;
00096         }
00097         
00098         function CreateSequence($seq='adodbseq',$start=1)
00099         {
00100                 
00101                 $this->Execute('BEGIN TRANSACTION adodbseq');
00102                 $start -= 1;
00103                 $this->Execute("create table $seq (id float(53))");
00104                 $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
00105                 if (!$ok) {
00106                                 $this->Execute('ROLLBACK TRANSACTION adodbseq');
00107                                 return false;
00108                 }
00109                 $this->Execute('COMMIT TRANSACTION adodbseq'); 
00110                 return true;
00111         }
00112 
00113         function GenID($seq='adodbseq',$start=1)
00114         {
00115                 //$this->debug=1;
00116                 $this->Execute('BEGIN TRANSACTION adodbseq');
00117                 $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
00118                 if (!$ok) {
00119                         $this->Execute("create table $seq (id float(53))");
00120                         $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
00121                         if (!$ok) {
00122                                 $this->Execute('ROLLBACK TRANSACTION adodbseq');
00123                                 return false;
00124                         }
00125                         $this->Execute('COMMIT TRANSACTION adodbseq'); 
00126                         return $start;
00127                 }
00128                 $num = $this->GetOne("select id from $seq");
00129                 $this->Execute('COMMIT TRANSACTION adodbseq'); 
00130                 return $num;
00131                 
00132                 // in old implementation, pre 1.90, we returned GUID...
00133                 //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'");
00134         }
00135         
00136         } // end class 
00137         
00138         class  ADORecordSet_ado_mssql extends ADORecordSet_ado {        
00139         
00140         var $databaseType = 'ado_mssql';
00141         
00142         function ADORecordSet_ado_mssql($id,$mode=false)
00143         {
00144                 return $this->ADORecordSet_ado($id,$mode);
00145         }
00146 }
00147 ?>