Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 /* 3 @version v5.21.0 2021-02-27 4 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved. 5 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community 6 Released under both BSD license and Lesser GPL library license. 7 Whenever there is any discrepancy between the two licenses, 8 the BSD license will take precedence. 9 Set tabs to 4 for best viewing. 10 11 Latest version is available at https://adodb.org/ 12 13 Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client. 14 Works only on MS Windows. 15 16 Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used. 17 Please check http://bugs.php.net/ for more info. 18 */ 19 20 // security - hide paths 21 if (!defined('ADODB_DIR')) die(); 22 23 if (!defined('_ADODB_ADO_LAYER')) { 24 include_once(ADODB_DIR . "/drivers/adodb-ado5.inc.php"); 25 } 26 27 28 class ADODB_ado_mssql extends ADODB_ado { 29 var $databaseType = 'ado_mssql'; 30 var $hasTop = 'top'; 31 var $hasInsertID = true; 32 var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; 33 var $sysTimeStamp = 'GetDate()'; 34 var $leftOuter = '*='; 35 var $rightOuter = '=*'; 36 var $ansiOuter = true; // for mssql7 or later 37 var $substr = "substring"; 38 var $length = 'len'; 39 var $_dropSeqSQL = "drop table %s"; 40 41 //var $_inTransaction = 1; // always open recordsets, so no transaction problems. 42 43 function _insertid() 44 { 45 return $this->GetOne('select SCOPE_IDENTITY()'); 46 } 47 48 function _affectedrows() 49 { 50 return $this->GetOne('select @@rowcount'); 51 } 52 53 function SetTransactionMode( $transaction_mode ) 54 { 55 $this->_transmode = $transaction_mode; 56 if (empty($transaction_mode)) { 57 $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); 58 return; 59 } 60 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; 61 $this->Execute("SET TRANSACTION ".$transaction_mode); 62 } 63 64 function qStr($s, $magic_quotes=false) 65 { 66 $s = ADOConnection::qStr($s); 67 return str_replace("\0", "\\\\000", $s); 68 } 69 70 function MetaColumns($table, $normalize=true) 71 { 72 $table = strtoupper($table); 73 $arr= array(); 74 $dbc = $this->_connectionID; 75 76 $osoptions = array(); 77 $osoptions[0] = null; 78 $osoptions[1] = null; 79 $osoptions[2] = $table; 80 $osoptions[3] = null; 81 82 $adors=@$dbc->OpenSchema(4, $osoptions);//tables 83 84 if ($adors){ 85 while (!$adors->EOF){ 86 $fld = new ADOFieldObject(); 87 $c = $adors->Fields(3); 88 $fld->name = $c->Value; 89 $fld->type = 'CHAR'; // cannot discover type in ADO! 90 $fld->max_length = -1; 91 $arr[strtoupper($fld->name)]=$fld; 92 93 $adors->MoveNext(); 94 } 95 $adors->Close(); 96 } 97 $false = false; 98 return empty($arr) ? $false : $arr; 99 } 100 101 function CreateSequence($seq='adodbseq',$start=1) 102 { 103 104 $this->Execute('BEGIN TRANSACTION adodbseq'); 105 $start -= 1; 106 $this->Execute("create table $seq (id float(53))"); 107 $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); 108 if (!$ok) { 109 $this->Execute('ROLLBACK TRANSACTION adodbseq'); 110 return false; 111 } 112 $this->Execute('COMMIT TRANSACTION adodbseq'); 113 return true; 114 } 115 116 function GenID($seq='adodbseq',$start=1) 117 { 118 //$this->debug=1; 119 $this->Execute('BEGIN TRANSACTION adodbseq'); 120 $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); 121 if (!$ok) { 122 $this->Execute("create table $seq (id float(53))"); 123 $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); 124 if (!$ok) { 125 $this->Execute('ROLLBACK TRANSACTION adodbseq'); 126 return false; 127 } 128 $this->Execute('COMMIT TRANSACTION adodbseq'); 129 return $start; 130 } 131 $num = $this->GetOne("select id from $seq"); 132 $this->Execute('COMMIT TRANSACTION adodbseq'); 133 return $num; 134 135 // in old implementation, pre 1.90, we returned GUID... 136 //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); 137 } 138 139 } // end class 140 141 class ADORecordSet_ado_mssql extends ADORecordSet_ado { 142 143 var $databaseType = 'ado_mssql'; 144 145 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body