blob: 74e11c3af4450a475a3e5f41acb55988f584c226 [file] [log] [blame]
Andrey Andreev0e8968a2012-01-26 02:04:37 +02001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Alex Bilbie84445d02011-03-10 16:43:39 +00002/**
3 * CodeIgniter
4 *
Phil Sturgeon07c1ac82012-03-09 17:03:37 +00005 * An open source application development framework for PHP 5.2.4 or newer
Alex Bilbie84445d02011-03-10 16:43:39 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreev0e8968a2012-01-26 02:04:37 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreev0e8968a2012-01-26 02:04:37 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Alex Bilbie84445d02011-03-10 16:43:39 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
Greg Aker0defe5d2012-01-01 18:46:41 -060021 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Alex Bilbie84445d02011-03-10 16:43:39 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
27
Alex Bilbie84445d02011-03-10 16:43:39 +000028/**
Alex Bilbie01ab0042011-03-18 19:24:30 +000029 * SQLSRV Database Adapter Class
Alex Bilbie84445d02011-03-10 16:43:39 +000030 *
31 * Note: _DB is an extender class that the app controller
Jamie Rumbelow7efad202012-02-19 12:37:00 +000032 * creates dynamically based on whether the query builder
Alex Bilbie84445d02011-03-10 16:43:39 +000033 * class is being used or not.
34 *
35 * @package CodeIgniter
36 * @subpackage Drivers
37 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050038 * @author EllisLab Dev Team
Alex Bilbie84445d02011-03-10 16:43:39 +000039 * @link http://codeigniter.com/user_guide/database/
40 */
Alex Bilbie01ab0042011-03-18 19:24:30 +000041class CI_DB_sqlsrv_driver extends CI_DB {
Alex Bilbie84445d02011-03-10 16:43:39 +000042
Andrey Andreev0e8968a2012-01-26 02:04:37 +020043 public $dbdriver = 'sqlsrv';
Alex Bilbie84445d02011-03-10 16:43:39 +000044
45 // The character used for escaping
Andrey Andreev0e8968a2012-01-26 02:04:37 +020046 protected $_escape_char = '';
Alex Bilbie84445d02011-03-10 16:43:39 +000047
48 // clause and character used for LIKE escape sequences
Andrey Andreeve6297342012-03-20 16:25:07 +020049 protected $_like_escape_str = " ESCAPE '%s' ";
Andrey Andreev0e8968a2012-01-26 02:04:37 +020050 protected $_like_escape_chr = '!';
Alex Bilbie84445d02011-03-10 16:43:39 +000051
52 /**
53 * The syntax to count rows is slightly different across different
54 * database engines, so this string appears in each driver and is
55 * used for the count_all() and count_all_results() functions.
56 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +020057 protected $_count_string = 'SELECT COUNT(*) AS ';
58 protected $_random_keyword = ' NEWID()';
Alex Bilbie84445d02011-03-10 16:43:39 +000059
60 /**
61 * Non-persistent database connection
62 *
Alex Bilbie84445d02011-03-10 16:43:39 +000063 * @return resource
64 */
Andrey Andreeve6297342012-03-20 16:25:07 +020065 public function db_connect($pooling = FALSE)
Alex Bilbie84445d02011-03-10 16:43:39 +000066 {
Alex Bilbie3a43c7a2011-03-18 19:48:04 +000067 // Check for a UTF-8 charset being passed as CI's default 'utf8'.
68 $character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set;
69
70 $connection = array(
Andrey Andreev0e8968a2012-01-26 02:04:37 +020071 'UID' => empty($this->username) ? '' : $this->username,
72 'PWD' => empty($this->password) ? '' : $this->password,
73 'Database' => $this->database,
74 'ConnectionPooling' => $pooling ? 1 : 0,
Alex Bilbie3a43c7a2011-03-18 19:48:04 +000075 'CharacterSet' => $character_set,
Andrey Andreev0e8968a2012-01-26 02:04:37 +020076 'ReturnDatesAsStrings' => 1
Alex Bilbie3a43c7a2011-03-18 19:48:04 +000077 );
Andrey Andreev0e8968a2012-01-26 02:04:37 +020078
79 // If the username and password are both empty, assume this is a
Alex Bilbie3a43c7a2011-03-18 19:48:04 +000080 // 'Windows Authentication Mode' connection.
Andrey Andreev0e8968a2012-01-26 02:04:37 +020081 if (empty($connection['UID']) && empty($connection['PWD']))
82 {
Alex Bilbie3a43c7a2011-03-18 19:48:04 +000083 unset($connection['UID'], $connection['PWD']);
Alex Bilbie84445d02011-03-10 16:43:39 +000084 }
85
Alex Bilbie3a43c7a2011-03-18 19:48:04 +000086 return sqlsrv_connect($this->hostname, $connection);
Alex Bilbie84445d02011-03-10 16:43:39 +000087 }
88
89 // --------------------------------------------------------------------
90
91 /**
92 * Persistent database connection
93 *
Alex Bilbie84445d02011-03-10 16:43:39 +000094 * @return resource
95 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +020096 public function db_pconnect()
Alex Bilbie84445d02011-03-10 16:43:39 +000097 {
Kyle Farris37e351f2011-09-07 11:14:46 -030098 return $this->db_connect(TRUE);
Alex Bilbie84445d02011-03-10 16:43:39 +000099 }
100
101 // --------------------------------------------------------------------
102
103 /**
Alex Bilbie84445d02011-03-10 16:43:39 +0000104 * Select the database
105 *
Andrey Andreev11454e02012-02-22 16:05:47 +0200106 * @param string database name
107 * @return bool
Alex Bilbie84445d02011-03-10 16:43:39 +0000108 */
Andrey Andreev11454e02012-02-22 16:05:47 +0200109 public function db_select($database = '')
Alex Bilbie84445d02011-03-10 16:43:39 +0000110 {
Andrey Andreev024ba2d2012-02-24 11:40:36 +0200111 if ($database === '')
112 {
113 $database = $this->database;
114 }
115
116 if ($this->_execute('USE '.$database))
117 {
118 $this->database = $database;
119 return TRUE;
120 }
121
122 return FALSE;
Alex Bilbie84445d02011-03-10 16:43:39 +0000123 }
124
125 // --------------------------------------------------------------------
126
127 /**
Alex Bilbie84445d02011-03-10 16:43:39 +0000128 * Execute the query
129 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000130 * @param string an SQL query
131 * @return resource
132 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200133 protected function _execute($sql)
Alex Bilbie84445d02011-03-10 16:43:39 +0000134 {
Andrey Andreev846acc72012-05-24 23:27:46 +0300135 return (is_write_type($sql) && stripos($sql, 'INSERT') === FALSE)
136 ? sqlsrv_query($this->conn_id, $sql)
137 : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => SQLSRV_CURSOR_STATIC));
Alex Bilbie84445d02011-03-10 16:43:39 +0000138 }
139
140 // --------------------------------------------------------------------
141
142 /**
143 * Begin Transaction
144 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000145 * @return bool
146 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200147 public function trans_begin($test_mode = FALSE)
Alex Bilbie84445d02011-03-10 16:43:39 +0000148 {
Alex Bilbie84445d02011-03-10 16:43:39 +0000149 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200150 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Alex Bilbie84445d02011-03-10 16:43:39 +0000151 {
152 return TRUE;
153 }
154
155 // Reset the transaction failure flag.
156 // If the $test_mode flag is set to TRUE transactions will be rolled back
157 // even if the queries produce a successful result.
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200158 $this->_trans_failure = ($test_mode === TRUE);
Alex Bilbie84445d02011-03-10 16:43:39 +0000159
Alex Bilbie3a43c7a2011-03-18 19:48:04 +0000160 return sqlsrv_begin_transaction($this->conn_id);
Alex Bilbie84445d02011-03-10 16:43:39 +0000161 }
162
163 // --------------------------------------------------------------------
164
165 /**
166 * Commit Transaction
167 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000168 * @return bool
169 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200170 public function trans_commit()
Alex Bilbie84445d02011-03-10 16:43:39 +0000171 {
Alex Bilbie84445d02011-03-10 16:43:39 +0000172 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200173 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Alex Bilbie84445d02011-03-10 16:43:39 +0000174 {
175 return TRUE;
176 }
177
Alex Bilbie3a43c7a2011-03-18 19:48:04 +0000178 return sqlsrv_commit($this->conn_id);
Alex Bilbie84445d02011-03-10 16:43:39 +0000179 }
180
181 // --------------------------------------------------------------------
182
183 /**
184 * Rollback Transaction
185 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000186 * @return bool
187 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200188 public function trans_rollback()
Alex Bilbie84445d02011-03-10 16:43:39 +0000189 {
Alex Bilbie84445d02011-03-10 16:43:39 +0000190 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200191 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Alex Bilbie84445d02011-03-10 16:43:39 +0000192 {
193 return TRUE;
194 }
195
Alex Bilbie3a43c7a2011-03-18 19:48:04 +0000196 return sqlsrv_rollback($this->conn_id);
Alex Bilbie84445d02011-03-10 16:43:39 +0000197 }
198
199 // --------------------------------------------------------------------
200
201 /**
202 * Escape String
203 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000204 * @param string
205 * @param bool whether or not the string will be used in a LIKE condition
206 * @return string
207 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200208 public function escape_str($str, $like = FALSE)
Alex Bilbie84445d02011-03-10 16:43:39 +0000209 {
Alex Bilbie84445d02011-03-10 16:43:39 +0000210 // Escape single quotes
Alex Bilbie3a43c7a2011-03-18 19:48:04 +0000211 return str_replace("'", "''", $str);
Alex Bilbie84445d02011-03-10 16:43:39 +0000212 }
213
214 // --------------------------------------------------------------------
215
216 /**
217 * Affected Rows
218 *
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200219 * @return int
Alex Bilbie84445d02011-03-10 16:43:39 +0000220 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200221 public function affected_rows()
Alex Bilbie84445d02011-03-10 16:43:39 +0000222 {
Andrey Andreev846acc72012-05-24 23:27:46 +0300223 return sqlrv_rows_affected($this->result_id);
Alex Bilbie84445d02011-03-10 16:43:39 +0000224 }
225
226 // --------------------------------------------------------------------
227
228 /**
Andrey Andreeve6297342012-03-20 16:25:07 +0200229 * Insert ID
230 *
231 * Returns the last id created in the Identity column.
232 *
233 * @return string
234 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200235 public function insert_id()
Alex Bilbie84445d02011-03-10 16:43:39 +0000236 {
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200237 $query = $this->query('SELECT @@IDENTITY AS insert_id');
238 $query = $query->row();
239 return $query->insert_id;
Alex Bilbie84445d02011-03-10 16:43:39 +0000240 }
241
242 // --------------------------------------------------------------------
243
244 /**
Andrey Andreev08856b82012-03-03 03:19:28 +0200245 * Database version number
246 *
247 * @return string
248 */
249 public function version()
Alex Bilbie84445d02011-03-10 16:43:39 +0000250 {
Andrey Andreev08856b82012-03-03 03:19:28 +0200251 if (isset($this->data_cache['version']))
252 {
253 return $this->data_cache['version'];
254 }
255
256 if (($info = sqlsrv_server_info($this->conn_id)) === FALSE)
257 {
258 return FALSE;
259 }
260
261 return $this->data_cache['version'] = $info['SQLServerVersion'];
Alex Bilbie84445d02011-03-10 16:43:39 +0000262 }
263
264 // --------------------------------------------------------------------
265
266 /**
Alex Bilbie84445d02011-03-10 16:43:39 +0000267 * List table query
268 *
269 * Generates a platform-specific query string so that the table names can be fetched
270 *
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200271 * @param bool
Alex Bilbie84445d02011-03-10 16:43:39 +0000272 * @return string
273 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200274 protected function _list_tables($prefix_limit = FALSE)
Alex Bilbie84445d02011-03-10 16:43:39 +0000275 {
Alex Bilbie3a43c7a2011-03-18 19:48:04 +0000276 return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
Alex Bilbie84445d02011-03-10 16:43:39 +0000277 }
278
279 // --------------------------------------------------------------------
280
281 /**
282 * List column query
283 *
284 * Generates a platform-specific query string so that the column names can be fetched
285 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000286 * @param string the table name
287 * @return string
288 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200289 protected function _list_columns($table = '')
Alex Bilbie84445d02011-03-10 16:43:39 +0000290 {
Andrey Andreeve6297342012-03-20 16:25:07 +0200291 return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
Alex Bilbie84445d02011-03-10 16:43:39 +0000292 }
293
294 // --------------------------------------------------------------------
295
296 /**
297 * Field data query
298 *
299 * Generates a platform-specific query so that the column data can be retrieved
300 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000301 * @param string the table name
Andrey Andreeve6297342012-03-20 16:25:07 +0200302 * @return string
Alex Bilbie84445d02011-03-10 16:43:39 +0000303 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200304 protected function _field_data($table)
Alex Bilbie84445d02011-03-10 16:43:39 +0000305 {
Andrey Andreeve6297342012-03-20 16:25:07 +0200306 return 'SELECT TOP 1 * FROM '.$table;
Alex Bilbie84445d02011-03-10 16:43:39 +0000307 }
308
309 // --------------------------------------------------------------------
310
311 /**
Andrey Andreev4be5de12012-03-02 15:45:41 +0200312 * Error
Alex Bilbie84445d02011-03-10 16:43:39 +0000313 *
Andrey Andreev4be5de12012-03-02 15:45:41 +0200314 * Returns an array containing code and message of the last
315 * database error that has occured.
Alex Bilbie84445d02011-03-10 16:43:39 +0000316 *
Andrey Andreev4be5de12012-03-02 15:45:41 +0200317 * @return array
Alex Bilbie84445d02011-03-10 16:43:39 +0000318 */
Andrey Andreev4be5de12012-03-02 15:45:41 +0200319 public function error()
Alex Bilbie84445d02011-03-10 16:43:39 +0000320 {
Andrey Andreev4be5de12012-03-02 15:45:41 +0200321 $error = array('code' => '00000', 'message' => '');
322 $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
323
324 if ( ! is_array($sqlsrv_errors))
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200325 {
Andrey Andreev4be5de12012-03-02 15:45:41 +0200326 return $error;
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200327 }
328
Andrey Andreev4be5de12012-03-02 15:45:41 +0200329 $sqlsrv_error = array_shift($sqlsrv_errors);
330 if (isset($sqlsrv_error['SQLSTATE']))
331 {
332 $error['code'] = isset($sqlsrv_error['code']) ? $sqlsrv_error['SQLSTATE'].'/'.$sqlsrv_error['code'] : $sqlsrv_error['SQLSTATE'];
333 }
334 elseif (isset($sqlsrv_error['code']))
335 {
336 $error['code'] = $sqlsrv_error['code'];
337 }
338
339 if (isset($sqlsrv_error['message']))
340 {
341 $error['message'] = $sqlsrv_error['message'];
342 }
343
344 return $error;
Alex Bilbie84445d02011-03-10 16:43:39 +0000345 }
346
347 // --------------------------------------------------------------------
348
349 /**
Alex Bilbie84445d02011-03-10 16:43:39 +0000350 * From Tables
351 *
352 * This function implicitly groups FROM tables so there is no confusion
353 * about operator precedence in harmony with SQL standards
354 *
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200355 * @param array
356 * @return string
Alex Bilbie84445d02011-03-10 16:43:39 +0000357 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200358 protected function _from_tables($tables)
Alex Bilbie84445d02011-03-10 16:43:39 +0000359 {
Andrey Andreevc78e56a2012-06-08 02:12:07 +0300360 return is_array($tables) ? implode(', ', $tables) : $tables;
Alex Bilbie84445d02011-03-10 16:43:39 +0000361 }
362
363 // --------------------------------------------------------------------
364
365 /**
Alex Bilbie84445d02011-03-10 16:43:39 +0000366 * Update statement
367 *
368 * Generates a platform-specific update string from the supplied data
369 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000370 * @param string the table name
371 * @param array the update data
372 * @param array the where clause
Andrey Andreev00541ae2012-04-09 11:43:10 +0300373 * @param array the orderby clause (ignored)
374 * @param array the limit clause (ignored)
375 * @param array the like clause
Alex Bilbie84445d02011-03-10 16:43:39 +0000376 * @return string
377 */
Andrey Andreev00541ae2012-04-09 11:43:10 +0300378 protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
Alex Bilbie84445d02011-03-10 16:43:39 +0000379 {
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200380 foreach ($values as $key => $val)
Alex Bilbie84445d02011-03-10 16:43:39 +0000381 {
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200382 $valstr[] = $key.' = '.$val;
Alex Bilbie84445d02011-03-10 16:43:39 +0000383 }
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200384
Andrey Andreev00541ae2012-04-09 11:43:10 +0300385 $where = empty($where) ? '' : ' WHERE '.implode(' ', $where);
386
387 if ( ! empty($like))
388 {
389 $where .= ($where === '' ? ' WHERE ' : ' AND ').implode(' ', $like);
390 }
391
st24b47e982012-04-24 17:45:44 +0800392 return 'UPDATE '.$table.' SET '.implode(', ', $valstr).$where;
Alex Bilbie84445d02011-03-10 16:43:39 +0000393 }
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200394
Alex Bilbie84445d02011-03-10 16:43:39 +0000395 // --------------------------------------------------------------------
396
397 /**
398 * Truncate statement
399 *
400 * Generates a platform-specific truncate string from the supplied data
Andrey Andreev6d83cde2012-04-05 16:20:50 +0300401 *
402 * If the database does not support the truncate() command,
403 * then this method maps to 'DELETE FROM table'
Alex Bilbie84445d02011-03-10 16:43:39 +0000404 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000405 * @param string the table name
406 * @return string
407 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200408 protected function _truncate($table)
Alex Bilbie84445d02011-03-10 16:43:39 +0000409 {
Andrey Andreev6d83cde2012-04-05 16:20:50 +0300410 return 'TRUNCATE TABLE '.$table;
Alex Bilbie84445d02011-03-10 16:43:39 +0000411 }
412
413 // --------------------------------------------------------------------
414
415 /**
416 * Delete statement
417 *
418 * Generates a platform-specific delete string from the supplied data
419 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000420 * @param string the table name
421 * @param array the where clause
Andrey Andreev5c0e9fe2012-04-09 12:28:11 +0300422 * @param array the like clause
Alex Bilbie84445d02011-03-10 16:43:39 +0000423 * @param string the limit clause
424 * @return string
425 */
Andrey Andreev5c0e9fe2012-04-09 12:28:11 +0300426 protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
Alex Bilbie84445d02011-03-10 16:43:39 +0000427 {
Andrey Andreev5c0e9fe2012-04-09 12:28:11 +0300428 $conditions = array();
429
430 empty($where) OR $conditions[] = implode(' ', $where);
431 empty($like) OR $conditions[] = implode(' ', $like);
432
433 $conditions = (count($conditions) > 0) ? ' WHERE '.implode(' AND ', $conditions) : '';
434
435 return ($limit)
436 ? 'WITH ci_delete AS (SELECT TOP '.$limit.' * FROM '.$table.$conditions.') DELETE FROM ci_delete'
437 : 'DELETE FROM '.$table.$conditions;
Alex Bilbie84445d02011-03-10 16:43:39 +0000438 }
439
440 // --------------------------------------------------------------------
441
442 /**
443 * Limit string
444 *
445 * Generates a platform-specific LIMIT clause
446 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000447 * @param string the sql query string
Andrey Andreeve6297342012-03-20 16:25:07 +0200448 * @param int the number of rows to limit the query to
449 * @param int the offset value
Alex Bilbie84445d02011-03-10 16:43:39 +0000450 * @return string
451 */
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200452 protected function _limit($sql, $limit, $offset)
Alex Bilbie84445d02011-03-10 16:43:39 +0000453 {
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200454 return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql);
Alex Bilbie84445d02011-03-10 16:43:39 +0000455 }
456
457 // --------------------------------------------------------------------
458
459 /**
460 * Close DB Connection
461 *
Alex Bilbie84445d02011-03-10 16:43:39 +0000462 * @return void
463 */
Andrey Andreev79922c02012-05-23 12:27:17 +0300464 protected function _close()
Alex Bilbie84445d02011-03-10 16:43:39 +0000465 {
Andrey Andreev79922c02012-05-23 12:27:17 +0300466 @sqlsrv_close($this->conn_id);
Alex Bilbie84445d02011-03-10 16:43:39 +0000467 }
468
469}
470
Andrey Andreev0e8968a2012-01-26 02:04:37 +0200471/* End of file sqlsrv_driver.php */
Andrey Andreev79922c02012-05-23 12:27:17 +0300472/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */