blob: 27b492f96a2c58c64f75028113f692541885196c [file] [log] [blame]
Derek Jones4b9c6292011-07-01 17:40:48 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
8 *
9 * Licensed under the Open Software License version 3.0
10 *
11 * 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 *
Derek Allard2067d1a2008-11-13 22:59:24 +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)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * MS SQL Database Adapter Class
32 *
33 * Note: _DB is an extender class that the app controller
34 * creates dynamically based on whether the active record
35 * class is being used or not.
36 *
37 * @package CodeIgniter
38 * @subpackage Drivers
39 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050040 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000041 * @link http://codeigniter.com/user_guide/database/
42 */
43class CI_DB_mssql_driver extends CI_DB {
44
45 var $dbdriver = 'mssql';
Barry Mienydd671972010-10-04 16:33:58 +020046
Derek Allard2067d1a2008-11-13 22:59:24 +000047 // The character used for escaping
48 var $_escape_char = '';
Derek Jonese4ed5832009-02-20 21:44:59 +000049
50 // clause and character used for LIKE escape sequences
51 var $_like_escape_str = " ESCAPE '%s' ";
52 var $_like_escape_chr = '!';
Barry Mienydd671972010-10-04 16:33:58 +020053
Derek Allard2067d1a2008-11-13 22:59:24 +000054 /**
55 * The syntax to count rows is slightly different across different
56 * database engines, so this string appears in each driver and is
57 * used for the count_all() and count_all_results() functions.
58 */
59 var $_count_string = "SELECT COUNT(*) AS ";
60 var $_random_keyword = ' ASC'; // not currently supported
61
62 /**
63 * Non-persistent database connection
64 *
65 * @access private called by the base class
66 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +020067 */
Derek Allard2067d1a2008-11-13 22:59:24 +000068 function db_connect()
69 {
70 if ($this->port != '')
71 {
72 $this->hostname .= ','.$this->port;
73 }
74
75 return @mssql_connect($this->hostname, $this->username, $this->password);
76 }
Barry Mienydd671972010-10-04 16:33:58 +020077
Derek Allard2067d1a2008-11-13 22:59:24 +000078 // --------------------------------------------------------------------
79
80 /**
81 * Persistent database connection
82 *
83 * @access private called by the base class
84 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +020085 */
Derek Allard2067d1a2008-11-13 22:59:24 +000086 function db_pconnect()
87 {
88 if ($this->port != '')
89 {
90 $this->hostname .= ','.$this->port;
91 }
92
93 return @mssql_pconnect($this->hostname, $this->username, $this->password);
94 }
Barry Mienydd671972010-10-04 16:33:58 +020095
Derek Allard2067d1a2008-11-13 22:59:24 +000096 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020097
Derek Jones87cbafc2009-02-27 16:29:59 +000098 /**
99 * Reconnect
100 *
101 * Keep / reestablish the db connection if no queries have been
102 * sent for a length of time exceeding the server's idle timeout
103 *
104 * @access public
105 * @return void
106 */
107 function reconnect()
108 {
109 // not implemented in MSSQL
110 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000111
Derek Jones87cbafc2009-02-27 16:29:59 +0000112 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200113
Derek Allard2067d1a2008-11-13 22:59:24 +0000114 /**
115 * Select the database
116 *
Andrey Andreev11454e02012-02-22 16:05:47 +0200117 * @param string database name
118 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200119 */
Andrey Andreev11454e02012-02-22 16:05:47 +0200120 public function db_select($database = '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000121 {
122 // Note: The brackets are required in the event that the DB name
123 // contains reserved characters
Andrey Andreev11454e02012-02-22 16:05:47 +0200124 return @mssql_select_db('['.($database == '' ? $this->database : $database).']', $this->conn_id);
Derek Allard2067d1a2008-11-13 22:59:24 +0000125 }
126
127 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200128
Derek Allard2067d1a2008-11-13 22:59:24 +0000129 /**
130 * Set client character set
131 *
132 * @access public
133 * @param string
134 * @param string
135 * @return resource
136 */
137 function db_set_charset($charset, $collation)
138 {
139 // @todo - add support if needed
140 return TRUE;
141 }
142
143 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200144
Derek Allard2067d1a2008-11-13 22:59:24 +0000145 /**
146 * Execute the query
147 *
148 * @access private called by the base class
149 * @param string an SQL query
150 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +0200151 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000152 function _execute($sql)
153 {
154 $sql = $this->_prep_query($sql);
155 return @mssql_query($sql, $this->conn_id);
156 }
Barry Mienydd671972010-10-04 16:33:58 +0200157
Derek Allard2067d1a2008-11-13 22:59:24 +0000158 // --------------------------------------------------------------------
159
160 /**
161 * Prep the query
162 *
163 * If needed, each database adapter can prep the query string
164 *
165 * @access private called by execute()
166 * @param string an SQL query
167 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200168 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000169 function _prep_query($sql)
170 {
171 return $sql;
172 }
173
174 // --------------------------------------------------------------------
175
176 /**
177 * Begin Transaction
178 *
179 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200180 * @return bool
181 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000182 function trans_begin($test_mode = FALSE)
183 {
184 if ( ! $this->trans_enabled)
185 {
186 return TRUE;
187 }
Barry Mienydd671972010-10-04 16:33:58 +0200188
Derek Allard2067d1a2008-11-13 22:59:24 +0000189 // When transactions are nested we only begin/commit/rollback the outermost ones
190 if ($this->_trans_depth > 0)
191 {
192 return TRUE;
193 }
194
195 // Reset the transaction failure flag.
196 // If the $test_mode flag is set to TRUE transactions will be rolled back
197 // even if the queries produce a successful result.
198 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
199
200 $this->simple_query('BEGIN TRAN');
201 return TRUE;
202 }
203
204 // --------------------------------------------------------------------
205
206 /**
207 * Commit Transaction
208 *
209 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200210 * @return bool
211 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000212 function trans_commit()
213 {
214 if ( ! $this->trans_enabled)
215 {
216 return TRUE;
217 }
218
219 // When transactions are nested we only begin/commit/rollback the outermost ones
220 if ($this->_trans_depth > 0)
221 {
222 return TRUE;
223 }
224
225 $this->simple_query('COMMIT TRAN');
226 return TRUE;
227 }
228
229 // --------------------------------------------------------------------
230
231 /**
232 * Rollback Transaction
233 *
234 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200235 * @return bool
236 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000237 function trans_rollback()
238 {
239 if ( ! $this->trans_enabled)
240 {
241 return TRUE;
242 }
243
244 // When transactions are nested we only begin/commit/rollback the outermost ones
245 if ($this->_trans_depth > 0)
246 {
247 return TRUE;
248 }
249
250 $this->simple_query('ROLLBACK TRAN');
251 return TRUE;
252 }
Barry Mienydd671972010-10-04 16:33:58 +0200253
Derek Allard2067d1a2008-11-13 22:59:24 +0000254 // --------------------------------------------------------------------
255
256 /**
257 * Escape String
258 *
259 * @access public
260 * @param string
Derek Jonese4ed5832009-02-20 21:44:59 +0000261 * @param bool whether or not the string will be used in a LIKE condition
Derek Allard2067d1a2008-11-13 22:59:24 +0000262 * @return string
263 */
Derek Jonese4ed5832009-02-20 21:44:59 +0000264 function escape_str($str, $like = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000265 {
Derek Jonese4ed5832009-02-20 21:44:59 +0000266 if (is_array($str))
267 {
Pascal Krietec3a4a8d2011-02-14 13:40:08 -0500268 foreach ($str as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200269 {
Derek Jonese4ed5832009-02-20 21:44:59 +0000270 $str[$key] = $this->escape_str($val, $like);
Barry Mienydd671972010-10-04 16:33:58 +0200271 }
272
273 return $str;
274 }
275
Derek Allard2067d1a2008-11-13 22:59:24 +0000276 // Escape single quotes
Greg Aker757dda62010-04-14 19:06:19 -0500277 $str = str_replace("'", "''", remove_invisible_characters($str));
Barry Mienydd671972010-10-04 16:33:58 +0200278
Derek Jonese4ed5832009-02-20 21:44:59 +0000279 // escape LIKE condition wildcards
280 if ($like === TRUE)
281 {
Phil Sturgeon36b0c942011-04-02 12:16:41 +0100282 $str = str_replace(
283 array($this->_like_escape_chr, '%', '_'),
284 array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
285 $str
286 );
Derek Jonese4ed5832009-02-20 21:44:59 +0000287 }
Barry Mienydd671972010-10-04 16:33:58 +0200288
Derek Jonese4ed5832009-02-20 21:44:59 +0000289 return $str;
Derek Allard2067d1a2008-11-13 22:59:24 +0000290 }
Barry Mienydd671972010-10-04 16:33:58 +0200291
Derek Allard2067d1a2008-11-13 22:59:24 +0000292 // --------------------------------------------------------------------
293
294 /**
295 * Affected Rows
296 *
297 * @access public
298 * @return integer
299 */
300 function affected_rows()
301 {
302 return @mssql_rows_affected($this->conn_id);
303 }
Barry Mienydd671972010-10-04 16:33:58 +0200304
Derek Allard2067d1a2008-11-13 22:59:24 +0000305 // --------------------------------------------------------------------
306
307 /**
308 * Insert ID
309 *
310 * Returns the last id created in the Identity column.
311 *
312 * @access public
313 * @return integer
314 */
315 function insert_id()
316 {
317 $ver = self::_parse_major_version($this->version());
318 $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
319 $query = $this->query($sql);
320 $row = $query->row();
321 return $row->last_id;
322 }
323
324 // --------------------------------------------------------------------
325
326 /**
327 * Parse major version
328 *
Barry Mienydd671972010-10-04 16:33:58 +0200329 * Grabs the major version number from the
Derek Allard2067d1a2008-11-13 22:59:24 +0000330 * database server version string passed in.
331 *
332 * @access private
333 * @param string $version
334 * @return int16 major version number
335 */
336 function _parse_major_version($version)
337 {
338 preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
339 return $ver_info[1]; // return the major version b/c that's all we're interested in.
340 }
341
342 // --------------------------------------------------------------------
343
344 /**
345 * Version number query string
346 *
347 * @access public
348 * @return string
349 */
350 function _version()
351 {
352 return "SELECT @@VERSION AS ver";
353 }
354
355 // --------------------------------------------------------------------
356
357 /**
358 * "Count All" query
359 *
360 * Generates a platform-specific query string that counts all records in
361 * the specified database
362 *
363 * @access public
364 * @param string
365 * @return string
366 */
367 function count_all($table = '')
368 {
369 if ($table == '')
Derek Allarde37ab382009-02-03 16:13:57 +0000370 {
371 return 0;
372 }
373
374 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
Derek Allard2067d1a2008-11-13 22:59:24 +0000375
376 if ($query->num_rows() == 0)
Derek Allarde37ab382009-02-03 16:13:57 +0000377 {
378 return 0;
379 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000380
381 $row = $query->row();
Greg Aker90248ab2011-08-20 14:23:14 -0500382 $this->_reset_select();
Derek Allarde37ab382009-02-03 16:13:57 +0000383 return (int) $row->numrows;
Derek Allard2067d1a2008-11-13 22:59:24 +0000384 }
385
386 // --------------------------------------------------------------------
387
388 /**
389 * List table query
390 *
391 * Generates a platform-specific query string so that the table names can be fetched
392 *
393 * @access private
394 * @param boolean
395 * @return string
396 */
397 function _list_tables($prefix_limit = FALSE)
398 {
399 $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
Barry Mienydd671972010-10-04 16:33:58 +0200400
Derek Allard2067d1a2008-11-13 22:59:24 +0000401 // for future compatibility
402 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
403 {
Greg Aker0d424892010-01-26 02:14:44 +0000404 //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
Derek Allard2067d1a2008-11-13 22:59:24 +0000405 return FALSE; // not currently supported
406 }
Barry Mienydd671972010-10-04 16:33:58 +0200407
Derek Allard2067d1a2008-11-13 22:59:24 +0000408 return $sql;
409 }
410
411 // --------------------------------------------------------------------
412
413 /**
414 * List column query
415 *
416 * Generates a platform-specific query string so that the column names can be fetched
417 *
418 * @access private
419 * @param string the table name
420 * @return string
421 */
422 function _list_columns($table = '')
423 {
Barry Mienydd671972010-10-04 16:33:58 +0200424 return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
Derek Allard2067d1a2008-11-13 22:59:24 +0000425 }
426
427 // --------------------------------------------------------------------
428
429 /**
430 * Field data query
431 *
432 * Generates a platform-specific query so that the column data can be retrieved
433 *
434 * @access public
435 * @param string the table name
436 * @return object
437 */
438 function _field_data($table)
439 {
Barry Mienydd671972010-10-04 16:33:58 +0200440 return "SELECT TOP 1 * FROM ".$table;
Derek Allard2067d1a2008-11-13 22:59:24 +0000441 }
442
443 // --------------------------------------------------------------------
444
445 /**
446 * The error message string
447 *
448 * @access private
449 * @return string
450 */
451 function _error_message()
452 {
Derek Allard64c398b2009-08-17 15:13:45 +0000453 return mssql_get_last_message();
Derek Allard2067d1a2008-11-13 22:59:24 +0000454 }
Barry Mienydd671972010-10-04 16:33:58 +0200455
Derek Allard2067d1a2008-11-13 22:59:24 +0000456 // --------------------------------------------------------------------
457
458 /**
459 * The error message number
460 *
461 * @access private
462 * @return integer
463 */
464 function _error_number()
465 {
466 // Are error numbers supported?
467 return '';
468 }
469
470 // --------------------------------------------------------------------
471
472 /**
473 * Escape the SQL Identifiers
474 *
475 * This function escapes column and table names
476 *
477 * @access private
478 * @param string
479 * @return string
480 */
481 function _escape_identifiers($item)
482 {
483 if ($this->_escape_char == '')
484 {
485 return $item;
486 }
487
488 foreach ($this->_reserved_identifiers as $id)
489 {
490 if (strpos($item, '.'.$id) !== FALSE)
491 {
Barry Mienydd671972010-10-04 16:33:58 +0200492 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
493
Derek Allard2067d1a2008-11-13 22:59:24 +0000494 // remove duplicates if the user already included the escape
495 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
Barry Mienydd671972010-10-04 16:33:58 +0200496 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000497 }
498
499 if (strpos($item, '.') !== FALSE)
500 {
Barry Mienydd671972010-10-04 16:33:58 +0200501 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
Derek Allard2067d1a2008-11-13 22:59:24 +0000502 }
503 else
504 {
505 $str = $this->_escape_char.$item.$this->_escape_char;
506 }
Barry Mienydd671972010-10-04 16:33:58 +0200507
Derek Allard2067d1a2008-11-13 22:59:24 +0000508 // remove duplicates if the user already included the escape
509 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
510 }
Barry Mienydd671972010-10-04 16:33:58 +0200511
Derek Allard2067d1a2008-11-13 22:59:24 +0000512 // --------------------------------------------------------------------
513
514 /**
515 * From Tables
516 *
517 * This function implicitly groups FROM tables so there is no confusion
518 * about operator precedence in harmony with SQL standards
519 *
520 * @access public
521 * @param type
522 * @return type
523 */
524 function _from_tables($tables)
525 {
526 if ( ! is_array($tables))
527 {
528 $tables = array($tables);
529 }
Barry Mienydd671972010-10-04 16:33:58 +0200530
Derek Allard2067d1a2008-11-13 22:59:24 +0000531 return implode(', ', $tables);
532 }
533
534 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200535
Derek Allard2067d1a2008-11-13 22:59:24 +0000536 /**
537 * Insert statement
538 *
539 * Generates a platform-specific insert string from the supplied data
540 *
541 * @access public
542 * @param string the table name
543 * @param array the insert keys
544 * @param array the insert values
545 * @return string
546 */
547 function _insert($table, $keys, $values)
Barry Mienydd671972010-10-04 16:33:58 +0200548 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000549 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
550 }
Barry Mienydd671972010-10-04 16:33:58 +0200551
Derek Allard2067d1a2008-11-13 22:59:24 +0000552 // --------------------------------------------------------------------
553
554 /**
555 * Update statement
556 *
557 * Generates a platform-specific update string from the supplied data
558 *
559 * @access public
560 * @param string the table name
561 * @param array the update data
562 * @param array the where clause
563 * @param array the orderby clause
564 * @param array the limit clause
565 * @return string
566 */
567 function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
568 {
Pascal Krietec3a4a8d2011-02-14 13:40:08 -0500569 foreach ($values as $key => $val)
Derek Allard2067d1a2008-11-13 22:59:24 +0000570 {
571 $valstr[] = $key." = ".$val;
572 }
Barry Mienydd671972010-10-04 16:33:58 +0200573
Derek Allard2067d1a2008-11-13 22:59:24 +0000574 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200575
Derek Allard2067d1a2008-11-13 22:59:24 +0000576 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
Barry Mienydd671972010-10-04 16:33:58 +0200577
Derek Allard2067d1a2008-11-13 22:59:24 +0000578 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
579
580 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
581
582 $sql .= $orderby.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200583
Derek Allard2067d1a2008-11-13 22:59:24 +0000584 return $sql;
585 }
586
Barry Mienydd671972010-10-04 16:33:58 +0200587
Derek Allard2067d1a2008-11-13 22:59:24 +0000588 // --------------------------------------------------------------------
589
590 /**
591 * Truncate statement
592 *
593 * Generates a platform-specific truncate string from the supplied data
594 * If the database does not support the truncate() command
595 * This function maps to "DELETE FROM table"
596 *
597 * @access public
598 * @param string the table name
599 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200600 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000601 function _truncate($table)
602 {
603 return "TRUNCATE ".$table;
604 }
Barry Mienydd671972010-10-04 16:33:58 +0200605
Derek Allard2067d1a2008-11-13 22:59:24 +0000606 // --------------------------------------------------------------------
607
608 /**
609 * Delete statement
610 *
611 * Generates a platform-specific delete string from the supplied data
612 *
613 * @access public
614 * @param string the table name
615 * @param array the where clause
616 * @param string the limit clause
617 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200618 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000619 function _delete($table, $where = array(), $like = array(), $limit = FALSE)
620 {
621 $conditions = '';
622
623 if (count($where) > 0 OR count($like) > 0)
624 {
625 $conditions = "\nWHERE ";
626 $conditions .= implode("\n", $this->ar_where);
627
628 if (count($where) > 0 && count($like) > 0)
629 {
630 $conditions .= " AND ";
631 }
632 $conditions .= implode("\n", $like);
633 }
634
635 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200636
Derek Allard2067d1a2008-11-13 22:59:24 +0000637 return "DELETE FROM ".$table.$conditions.$limit;
638 }
639
640 // --------------------------------------------------------------------
641
642 /**
643 * Limit string
644 *
645 * Generates a platform-specific LIMIT clause
646 *
647 * @access public
648 * @param string the sql query string
649 * @param integer the number of rows to limit the query to
650 * @param integer the offset value
651 * @return string
652 */
653 function _limit($sql, $limit, $offset)
654 {
655 $i = $limit + $offset;
Barry Mienydd671972010-10-04 16:33:58 +0200656
657 return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
Derek Allard2067d1a2008-11-13 22:59:24 +0000658 }
659
660 // --------------------------------------------------------------------
661
662 /**
663 * Close DB Connection
664 *
665 * @access public
666 * @param resource
667 * @return void
668 */
669 function _close($conn_id)
670 {
671 @mssql_close($conn_id);
Barry Mienydd671972010-10-04 16:33:58 +0200672 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000673
674}
675
676
677
678/* End of file mssql_driver.php */
Andrey Andreev11454e02012-02-22 16:05:47 +0200679/* Location: ./system/database/drivers/mssql/mssql_driver.php */