Ignore:
Timestamp:
06/29/07 15:17:46 (17 years ago)
Author:
niltonneto
Message:

Versão nova do ADODB (4.5 para 4.95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/adodb/drivers/adodb-ado_mssql.inc.php

    r2 r34  
    11<?php 
    22/*  
    3 V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved. 
     3V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    1212  Works only on MS Windows. 
    1313   
    14   It is normally better to use the mssql driver directly because it is much faster.  
    15   This file is only a technology demonstration and for test purposes. 
     14  Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used.  
     15  Please check http://bugs.php.net/ for more info. 
    1616*/ 
    1717 
     
    2020 
    2121if (!defined('_ADODB_ADO_LAYER')) { 
    22         include(ADODB_DIR."/drivers/adodb-ado.inc.php"); 
     22        if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php"); 
     23        else include(ADODB_DIR."/drivers/adodb-ado.inc.php"); 
    2324} 
    2425 
     
    3536        var $substr = "substring"; 
    3637        var $length = 'len'; 
     38        var $_dropSeqSQL = "drop table %s"; 
    3739         
    3840        //var $_inTransaction = 1; // always open recordsets, so no transaction problems. 
     
    5355        } 
    5456         
     57        function SetTransactionMode( $transaction_mode )  
     58        { 
     59                $this->_transmode  = $transaction_mode; 
     60                if (empty($transaction_mode)) { 
     61                        $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); 
     62                        return; 
     63                } 
     64                if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; 
     65                $this->Execute("SET TRANSACTION ".$transaction_mode); 
     66        } 
     67         
     68        function qstr($s,$magic_quotes=false) 
     69        { 
     70                $s = ADOConnection::qstr($s, $magic_quotes); 
     71                return str_replace("\0", "\\\\000", $s); 
     72        } 
     73         
    5574        function MetaColumns($table) 
    5675        { 
    57                 $table = strtoupper($table); 
    58                 $arr= array(); 
    59                 $dbc = $this->_connectionID; 
    60                  
    61                 $osoptions = array(); 
    62                 $osoptions[0] = null; 
    63                 $osoptions[1] = null; 
    64                 $osoptions[2] = $table; 
    65                 $osoptions[3] = null; 
    66                  
    67                 $adors=@$dbc->OpenSchema(4, $osoptions);//tables 
     76        $table = strtoupper($table); 
     77        $arr= array(); 
     78        $dbc = $this->_connectionID; 
     79         
     80        $osoptions = array(); 
     81        $osoptions[0] = null; 
     82        $osoptions[1] = null; 
     83        $osoptions[2] = $table; 
     84        $osoptions[3] = null; 
     85         
     86        $adors=@$dbc->OpenSchema(4, $osoptions);//tables 
     87 
     88        if ($adors){ 
     89                while (!$adors->EOF){ 
     90                        $fld = new ADOFieldObject(); 
     91                        $c = $adors->Fields(3); 
     92                        $fld->name = $c->Value; 
     93                        $fld->type = 'CHAR'; // cannot discover type in ADO! 
     94                        $fld->max_length = -1; 
     95                        $arr[strtoupper($fld->name)]=$fld; 
     96         
     97                        $adors->MoveNext(); 
     98                } 
     99                $adors->Close(); 
     100        } 
     101        $false = false; 
     102                return empty($arr) ? $false : $arr; 
     103        } 
    68104         
    69                 if ($adors){ 
    70                         while (!$adors->EOF){ 
    71                                 $fld = new ADOFieldObject(); 
    72                                 $c = $adors->Fields(3); 
    73                                 $fld->name = $c->Value; 
    74                                 $fld->type = 'CHAR'; // cannot discover type in ADO! 
    75                                 $fld->max_length = -1; 
    76                                 $arr[strtoupper($fld->name)]=$fld; 
    77                  
    78                                 $adors->MoveNext(); 
    79                         } 
    80                         $adors->Close(); 
    81                 } 
    82                  
    83                 return $arr; 
     105        function CreateSequence($seq='adodbseq',$start=1) 
     106        { 
     107                 
     108                $this->Execute('BEGIN TRANSACTION adodbseq'); 
     109                $start -= 1; 
     110                $this->Execute("create table $seq (id float(53))"); 
     111                $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); 
     112                if (!$ok) { 
     113                                $this->Execute('ROLLBACK TRANSACTION adodbseq'); 
     114                                return false; 
     115                } 
     116                $this->Execute('COMMIT TRANSACTION adodbseq');  
     117                return true; 
    84118        } 
     119 
     120        function GenID($seq='adodbseq',$start=1) 
     121        { 
     122                //$this->debug=1; 
     123                $this->Execute('BEGIN TRANSACTION adodbseq'); 
     124                $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); 
     125                if (!$ok) { 
     126                        $this->Execute("create table $seq (id float(53))"); 
     127                        $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); 
     128                        if (!$ok) { 
     129                                $this->Execute('ROLLBACK TRANSACTION adodbseq'); 
     130                                return false; 
     131                        } 
     132                        $this->Execute('COMMIT TRANSACTION adodbseq');  
     133                        return $start; 
     134                } 
     135                $num = $this->GetOne("select id from $seq"); 
     136                $this->Execute('COMMIT TRANSACTION adodbseq');  
     137                return $num; 
     138                 
     139                // in old implementation, pre 1.90, we returned GUID... 
     140                //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); 
    85141        } 
     142         
     143        } // end class  
    86144         
    87145        class  ADORecordSet_ado_mssql extends ADORecordSet_ado {         
Note: See TracChangeset for help on using the changeset viewer.