Documentation TYPO3 par Ameos

adodb-ado_mssql.inc.php

00001 <?php
00002 /* 
00003 V4.93 10 Oct 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         var $_dropSeqSQL = "drop table %s";
00039         
00040         //var $_inTransaction = 1; // always open recordsets, so no transaction problems.
00041         
00042         function ADODB_ado_mssql()
00043         {
00044                 $this->ADODB_ado();
00045         }
00046         
00047         function _insertid()
00048         {
00049                 return $this->GetOne('select @@identity');
00050         }
00051         
00052         function _affectedrows()
00053         {
00054                 return $this->GetOne('select @@rowcount');
00055         }
00056         
00057         function SetTransactionMode( $transaction_mode ) 
00058         {
00059                 $this->_transmode  = $transaction_mode;
00060                 if (empty($transaction_mode)) {
00061                         $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
00062                         return;
00063                 }
00064                 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
00065                 $this->Execute("SET TRANSACTION ".$transaction_mode);
00066         }
00067         
00068         function MetaColumns($table)
00069         {
00070         $table = strtoupper($table);
00071         $arr= array();
00072         $dbc = $this->_connectionID;
00073         
00074         $osoptions = array();
00075         $osoptions[0] = null;
00076         $osoptions[1] = null;
00077         $osoptions[2] = $table;
00078         $osoptions[3] = null;
00079         
00080         $adors=@$dbc->OpenSchema(4, $osoptions);//tables
00081 
00082         if ($adors){
00083                 while (!$adors->EOF){
00084                         $fld = new ADOFieldObject();
00085                         $c = $adors->Fields(3);
00086                         $fld->name = $c->Value;
00087                         $fld->type = 'CHAR'; // cannot discover type in ADO!
00088                         $fld->max_length = -1;
00089                         $arr[strtoupper($fld->name)]=$fld;
00090         
00091                         $adors->MoveNext();
00092                 }
00093                 $adors->Close();
00094         }
00095         $false = false;
00096                 return empty($arr) ? $false : $arr;
00097         }
00098         
00099         function CreateSequence($seq='adodbseq',$start=1)
00100         {
00101                 
00102                 $this->Execute('BEGIN TRANSACTION adodbseq');
00103                 $start -= 1;
00104                 $this->Execute("create table $seq (id float(53))");
00105                 $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
00106                 if (!$ok) {
00107                                 $this->Execute('ROLLBACK TRANSACTION adodbseq');
00108                                 return false;
00109                 }
00110                 $this->Execute('COMMIT TRANSACTION adodbseq'); 
00111                 return true;
00112         }
00113 
00114         function GenID($seq='adodbseq',$start=1)
00115         {
00116                 //$this->debug=1;
00117                 $this->Execute('BEGIN TRANSACTION adodbseq');
00118                 $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
00119                 if (!$ok) {
00120                         $this->Execute("create table $seq (id float(53))");
00121                         $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
00122                         if (!$ok) {
00123                                 $this->Execute('ROLLBACK TRANSACTION adodbseq');
00124                                 return false;
00125                         }
00126                         $this->Execute('COMMIT TRANSACTION adodbseq'); 
00127                         return $start;
00128                 }
00129                 $num = $this->GetOne("select id from $seq");
00130                 $this->Execute('COMMIT TRANSACTION adodbseq'); 
00131                 return $num;
00132                 
00133                 // in old implementation, pre 1.90, we returned GUID...
00134                 //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'");
00135         }
00136         
00137         } // end class 
00138         
00139         class  ADORecordSet_ado_mssql extends ADORecordSet_ado {        
00140         
00141         var $databaseType = 'ado_mssql';
00142         
00143         function ADORecordSet_ado_mssql($id,$mode=false)
00144         {
00145                 return $this->ADORecordSet_ado($id,$mode);
00146         }
00147 }
00148 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6