1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
<?php
/**
* PDO sqlsrv driver
*
* This file is part of ADOdb, a Database Abstraction Layer library for PHP.
*
* @package ADOdb
* @link https://adodb.org Project's web site and documentation
* @link https://github.com/ADOdb/ADOdb Source code and issue tracker
*
* The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
* and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
* any later version. This means you can use it in proprietary products.
* See the LICENSE.md file distributed with this source code for details.
* @license BSD-3-Clause
* @license LGPL-2.1-or-later
*
* @copyright 2000-2013 John Lim
* @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
* @author Ned Andre
*/
class ADODB_pdo_sqlsrv extends ADODB_pdo
{
var $hasTop = 'top';
var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
var $sysTimeStamp = 'GetDate()';
var $arrayClass = 'ADORecordSet_array_pdo_sqlsrv';
function _init(ADODB_pdo $parentDriver)
{
$parentDriver->hasTransactions = true;
$parentDriver->_bindInputArray = true;
$parentDriver->hasInsertID = true;
$parentDriver->fmtTimeStamp = "'Y-m-d H:i:s'";
$parentDriver->fmtDate = "'Y-m-d'";
}
function BeginTrans()
{
$returnval = parent::BeginTrans();
return $returnval;
}
function MetaColumns($table, $normalize = true)
{
return false;
}
function MetaTables($ttype = false, $showSchema = false, $mask = false)
{
return false;
}
function SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
{
$ret = ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
return $ret;
}
function ServerInfo()
{
return ADOConnection::ServerInfo();
}
}
class ADORecordSet_pdo_sqlsrv extends ADORecordSet_pdo
{
public $databaseType = "pdo_sqlsrv";
/**
* returns the field object
*
* @param int $fieldOffset Optional field offset
*
* @return object The ADOFieldObject describing the field
*/
public function fetchField($fieldOffset = 0)
{
// Default behavior allows passing in of -1 offset, which crashes the method
if ($fieldOffset == -1) {
$fieldOffset++;
}
$o = new ADOFieldObject();
$arr = @$this->_queryID->getColumnMeta($fieldOffset);
if (!$arr) {
$o->name = 'bad getColumnMeta()';
$o->max_length = -1;
$o->type = 'VARCHAR';
$o->precision = 0;
return $o;
}
$o->name = $arr['name'];
if (isset($arr['sqlsrv:decl_type']) && $arr['sqlsrv:decl_type'] <> "null") {
// Use the SQL Server driver specific value
$o->type = $arr['sqlsrv:decl_type'];
} else {
$o->type = adodb_pdo_type($arr['pdo_type']);
}
$o->max_length = $arr['len'];
$o->precision = $arr['precision'];
switch (ADODB_ASSOC_CASE) {
case ADODB_ASSOC_CASE_LOWER:
$o->name = strtolower($o->name);
break;
case ADODB_ASSOC_CASE_UPPER:
$o->name = strtoupper($o->name);
break;
}
return $o;
}
}
class ADORecordSet_array_pdo_sqlsrv extends ADORecordSet_array_pdo
{
/**
* returns the field object
*
* Note that this is a direct copy of the ADORecordSet_pdo_sqlsrv method
*
* @param int $fieldOffset Optional field offset
*
* @return object The ADOfieldobject describing the field
*/
public function fetchField($fieldOffset = 0)
{
// Default behavior allows passing in of -1 offset, which crashes the method
if ($fieldOffset == -1) {
$fieldOffset++;
}
$o = new ADOFieldObject();
$arr = @$this->_queryID->getColumnMeta($fieldOffset);
if (!$arr) {
$o->name = 'bad getColumnMeta()';
$o->max_length = -1;
$o->type = 'VARCHAR';
$o->precision = 0;
return $o;
}
$o->name = $arr['name'];
if (isset($arr['sqlsrv:decl_type']) && $arr['sqlsrv:decl_type'] <> "null") {
// Use the SQL Server driver specific value
$o->type = $arr['sqlsrv:decl_type'];
} else {
$o->type = adodb_pdo_type($arr['pdo_type']);
}
$o->max_length = $arr['len'];
$o->precision = $arr['precision'];
switch (ADODB_ASSOC_CASE) {
case ADODB_ASSOC_CASE_LOWER:
$o->name = strtolower($o->name);
break;
case ADODB_ASSOC_CASE_UPPER:
$o->name = strtoupper($o->name);
break;
}
return $o;
}
function SetTransactionMode( $transaction_mode )
{
$this->_transmode = $transaction_mode;
if (empty($transaction_mode)) {
$this->_connectionID->query('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
return;
}
if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
$this->_connectionID->query("SET TRANSACTION ".$transaction_mode);
}
}
|