blob: 2a4f2b575c512fdbdb6dca6f204477c78663170b [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 {
Andrey Andreev024ba2d2012-02-24 11:40:36 +0200122 if ($database === '')
123 {
124 $database = $this->database;
125 }
126
Derek Allard2067d1a2008-11-13 22:59:24 +0000127 // Note: The brackets are required in the event that the DB name
128 // contains reserved characters
Andrey Andreev024ba2d2012-02-24 11:40:36 +0200129 if (@mssql_select_db('['.$database.']', $this->conn_id))
130 {
131 $this->database = $database;
132 return TRUE;
133 }
134
135 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000136 }
137
138 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200139
Derek Allard2067d1a2008-11-13 22:59:24 +0000140 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000141 * Execute the query
142 *
143 * @access private called by the base class
144 * @param string an SQL query
145 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +0200146 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000147 function _execute($sql)
148 {
149 $sql = $this->_prep_query($sql);
150 return @mssql_query($sql, $this->conn_id);
151 }
Barry Mienydd671972010-10-04 16:33:58 +0200152
Derek Allard2067d1a2008-11-13 22:59:24 +0000153 // --------------------------------------------------------------------
154
155 /**
156 * Prep the query
157 *
158 * If needed, each database adapter can prep the query string
159 *
160 * @access private called by execute()
161 * @param string an SQL query
162 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200163 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000164 function _prep_query($sql)
165 {
166 return $sql;
167 }
168
169 // --------------------------------------------------------------------
170
171 /**
172 * Begin Transaction
173 *
174 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200175 * @return bool
176 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000177 function trans_begin($test_mode = FALSE)
178 {
179 if ( ! $this->trans_enabled)
180 {
181 return TRUE;
182 }
Barry Mienydd671972010-10-04 16:33:58 +0200183
Derek Allard2067d1a2008-11-13 22:59:24 +0000184 // When transactions are nested we only begin/commit/rollback the outermost ones
185 if ($this->_trans_depth > 0)
186 {
187 return TRUE;
188 }
189
190 // Reset the transaction failure flag.
191 // If the $test_mode flag is set to TRUE transactions will be rolled back
192 // even if the queries produce a successful result.
193 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
194
195 $this->simple_query('BEGIN TRAN');
196 return TRUE;
197 }
198
199 // --------------------------------------------------------------------
200
201 /**
202 * Commit Transaction
203 *
204 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200205 * @return bool
206 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000207 function trans_commit()
208 {
209 if ( ! $this->trans_enabled)
210 {
211 return TRUE;
212 }
213
214 // When transactions are nested we only begin/commit/rollback the outermost ones
215 if ($this->_trans_depth > 0)
216 {
217 return TRUE;
218 }
219
220 $this->simple_query('COMMIT TRAN');
221 return TRUE;
222 }
223
224 // --------------------------------------------------------------------
225
226 /**
227 * Rollback Transaction
228 *
229 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200230 * @return bool
231 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000232 function trans_rollback()
233 {
234 if ( ! $this->trans_enabled)
235 {
236 return TRUE;
237 }
238
239 // When transactions are nested we only begin/commit/rollback the outermost ones
240 if ($this->_trans_depth > 0)
241 {
242 return TRUE;
243 }
244
245 $this->simple_query('ROLLBACK TRAN');
246 return TRUE;
247 }
Barry Mienydd671972010-10-04 16:33:58 +0200248
Derek Allard2067d1a2008-11-13 22:59:24 +0000249 // --------------------------------------------------------------------
250
251 /**
252 * Escape String
253 *
254 * @access public
255 * @param string
Derek Jonese4ed5832009-02-20 21:44:59 +0000256 * @param bool whether or not the string will be used in a LIKE condition
Derek Allard2067d1a2008-11-13 22:59:24 +0000257 * @return string
258 */
Derek Jonese4ed5832009-02-20 21:44:59 +0000259 function escape_str($str, $like = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000260 {
Derek Jonese4ed5832009-02-20 21:44:59 +0000261 if (is_array($str))
262 {
Pascal Krietec3a4a8d2011-02-14 13:40:08 -0500263 foreach ($str as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200264 {
Derek Jonese4ed5832009-02-20 21:44:59 +0000265 $str[$key] = $this->escape_str($val, $like);
Barry Mienydd671972010-10-04 16:33:58 +0200266 }
267
268 return $str;
269 }
270
Derek Allard2067d1a2008-11-13 22:59:24 +0000271 // Escape single quotes
Greg Aker757dda62010-04-14 19:06:19 -0500272 $str = str_replace("'", "''", remove_invisible_characters($str));
Barry Mienydd671972010-10-04 16:33:58 +0200273
Derek Jonese4ed5832009-02-20 21:44:59 +0000274 // escape LIKE condition wildcards
275 if ($like === TRUE)
276 {
Phil Sturgeon36b0c942011-04-02 12:16:41 +0100277 $str = str_replace(
278 array($this->_like_escape_chr, '%', '_'),
279 array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
280 $str
281 );
Derek Jonese4ed5832009-02-20 21:44:59 +0000282 }
Barry Mienydd671972010-10-04 16:33:58 +0200283
Derek Jonese4ed5832009-02-20 21:44:59 +0000284 return $str;
Derek Allard2067d1a2008-11-13 22:59:24 +0000285 }
Barry Mienydd671972010-10-04 16:33:58 +0200286
Derek Allard2067d1a2008-11-13 22:59:24 +0000287 // --------------------------------------------------------------------
288
289 /**
290 * Affected Rows
291 *
292 * @access public
293 * @return integer
294 */
295 function affected_rows()
296 {
297 return @mssql_rows_affected($this->conn_id);
298 }
Barry Mienydd671972010-10-04 16:33:58 +0200299
Derek Allard2067d1a2008-11-13 22:59:24 +0000300 // --------------------------------------------------------------------
301
302 /**
303 * Insert ID
304 *
305 * Returns the last id created in the Identity column.
306 *
307 * @access public
308 * @return integer
309 */
310 function insert_id()
311 {
312 $ver = self::_parse_major_version($this->version());
313 $sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
314 $query = $this->query($sql);
315 $row = $query->row();
316 return $row->last_id;
317 }
318
319 // --------------------------------------------------------------------
320
321 /**
322 * Parse major version
323 *
Barry Mienydd671972010-10-04 16:33:58 +0200324 * Grabs the major version number from the
Derek Allard2067d1a2008-11-13 22:59:24 +0000325 * database server version string passed in.
326 *
327 * @access private
328 * @param string $version
329 * @return int16 major version number
330 */
331 function _parse_major_version($version)
332 {
333 preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
334 return $ver_info[1]; // return the major version b/c that's all we're interested in.
335 }
336
337 // --------------------------------------------------------------------
338
339 /**
340 * Version number query string
341 *
342 * @access public
343 * @return string
344 */
345 function _version()
346 {
347 return "SELECT @@VERSION AS ver";
348 }
349
350 // --------------------------------------------------------------------
351
352 /**
353 * "Count All" query
354 *
355 * Generates a platform-specific query string that counts all records in
356 * the specified database
357 *
358 * @access public
359 * @param string
360 * @return string
361 */
362 function count_all($table = '')
363 {
364 if ($table == '')
Derek Allarde37ab382009-02-03 16:13:57 +0000365 {
366 return 0;
367 }
368
369 $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 +0000370
371 if ($query->num_rows() == 0)
Derek Allarde37ab382009-02-03 16:13:57 +0000372 {
373 return 0;
374 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000375
376 $row = $query->row();
Greg Aker90248ab2011-08-20 14:23:14 -0500377 $this->_reset_select();
Derek Allarde37ab382009-02-03 16:13:57 +0000378 return (int) $row->numrows;
Derek Allard2067d1a2008-11-13 22:59:24 +0000379 }
380
381 // --------------------------------------------------------------------
382
383 /**
384 * List table query
385 *
386 * Generates a platform-specific query string so that the table names can be fetched
387 *
388 * @access private
389 * @param boolean
390 * @return string
391 */
392 function _list_tables($prefix_limit = FALSE)
393 {
394 $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
Barry Mienydd671972010-10-04 16:33:58 +0200395
Derek Allard2067d1a2008-11-13 22:59:24 +0000396 // for future compatibility
397 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
398 {
Greg Aker0d424892010-01-26 02:14:44 +0000399 //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
Derek Allard2067d1a2008-11-13 22:59:24 +0000400 return FALSE; // not currently supported
401 }
Barry Mienydd671972010-10-04 16:33:58 +0200402
Derek Allard2067d1a2008-11-13 22:59:24 +0000403 return $sql;
404 }
405
406 // --------------------------------------------------------------------
407
408 /**
409 * List column query
410 *
411 * Generates a platform-specific query string so that the column names can be fetched
412 *
413 * @access private
414 * @param string the table name
415 * @return string
416 */
417 function _list_columns($table = '')
418 {
Barry Mienydd671972010-10-04 16:33:58 +0200419 return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
Derek Allard2067d1a2008-11-13 22:59:24 +0000420 }
421
422 // --------------------------------------------------------------------
423
424 /**
425 * Field data query
426 *
427 * Generates a platform-specific query so that the column data can be retrieved
428 *
429 * @access public
430 * @param string the table name
431 * @return object
432 */
433 function _field_data($table)
434 {
Barry Mienydd671972010-10-04 16:33:58 +0200435 return "SELECT TOP 1 * FROM ".$table;
Derek Allard2067d1a2008-11-13 22:59:24 +0000436 }
437
438 // --------------------------------------------------------------------
439
440 /**
441 * The error message string
442 *
443 * @access private
444 * @return string
445 */
446 function _error_message()
447 {
Derek Allard64c398b2009-08-17 15:13:45 +0000448 return mssql_get_last_message();
Derek Allard2067d1a2008-11-13 22:59:24 +0000449 }
Barry Mienydd671972010-10-04 16:33:58 +0200450
Derek Allard2067d1a2008-11-13 22:59:24 +0000451 // --------------------------------------------------------------------
452
453 /**
454 * The error message number
455 *
456 * @access private
457 * @return integer
458 */
459 function _error_number()
460 {
461 // Are error numbers supported?
462 return '';
463 }
464
465 // --------------------------------------------------------------------
466
467 /**
468 * Escape the SQL Identifiers
469 *
470 * This function escapes column and table names
471 *
472 * @access private
473 * @param string
474 * @return string
475 */
476 function _escape_identifiers($item)
477 {
478 if ($this->_escape_char == '')
479 {
480 return $item;
481 }
482
483 foreach ($this->_reserved_identifiers as $id)
484 {
485 if (strpos($item, '.'.$id) !== FALSE)
486 {
Barry Mienydd671972010-10-04 16:33:58 +0200487 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
488
Derek Allard2067d1a2008-11-13 22:59:24 +0000489 // remove duplicates if the user already included the escape
490 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
Barry Mienydd671972010-10-04 16:33:58 +0200491 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000492 }
493
494 if (strpos($item, '.') !== FALSE)
495 {
Barry Mienydd671972010-10-04 16:33:58 +0200496 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
Derek Allard2067d1a2008-11-13 22:59:24 +0000497 }
498 else
499 {
500 $str = $this->_escape_char.$item.$this->_escape_char;
501 }
Barry Mienydd671972010-10-04 16:33:58 +0200502
Derek Allard2067d1a2008-11-13 22:59:24 +0000503 // remove duplicates if the user already included the escape
504 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
505 }
Barry Mienydd671972010-10-04 16:33:58 +0200506
Derek Allard2067d1a2008-11-13 22:59:24 +0000507 // --------------------------------------------------------------------
508
509 /**
510 * From Tables
511 *
512 * This function implicitly groups FROM tables so there is no confusion
513 * about operator precedence in harmony with SQL standards
514 *
515 * @access public
516 * @param type
517 * @return type
518 */
519 function _from_tables($tables)
520 {
521 if ( ! is_array($tables))
522 {
523 $tables = array($tables);
524 }
Barry Mienydd671972010-10-04 16:33:58 +0200525
Derek Allard2067d1a2008-11-13 22:59:24 +0000526 return implode(', ', $tables);
527 }
528
529 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200530
Derek Allard2067d1a2008-11-13 22:59:24 +0000531 /**
532 * Insert statement
533 *
534 * Generates a platform-specific insert string from the supplied data
535 *
536 * @access public
537 * @param string the table name
538 * @param array the insert keys
539 * @param array the insert values
540 * @return string
541 */
542 function _insert($table, $keys, $values)
Barry Mienydd671972010-10-04 16:33:58 +0200543 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000544 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
545 }
Barry Mienydd671972010-10-04 16:33:58 +0200546
Derek Allard2067d1a2008-11-13 22:59:24 +0000547 // --------------------------------------------------------------------
548
549 /**
550 * Update statement
551 *
552 * Generates a platform-specific update string from the supplied data
553 *
554 * @access public
555 * @param string the table name
556 * @param array the update data
557 * @param array the where clause
558 * @param array the orderby clause
559 * @param array the limit clause
560 * @return string
561 */
562 function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
563 {
Pascal Krietec3a4a8d2011-02-14 13:40:08 -0500564 foreach ($values as $key => $val)
Derek Allard2067d1a2008-11-13 22:59:24 +0000565 {
566 $valstr[] = $key." = ".$val;
567 }
Barry Mienydd671972010-10-04 16:33:58 +0200568
Derek Allard2067d1a2008-11-13 22:59:24 +0000569 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200570
Derek Allard2067d1a2008-11-13 22:59:24 +0000571 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
Barry Mienydd671972010-10-04 16:33:58 +0200572
Derek Allard2067d1a2008-11-13 22:59:24 +0000573 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
574
575 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
576
577 $sql .= $orderby.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200578
Derek Allard2067d1a2008-11-13 22:59:24 +0000579 return $sql;
580 }
581
Barry Mienydd671972010-10-04 16:33:58 +0200582
Derek Allard2067d1a2008-11-13 22:59:24 +0000583 // --------------------------------------------------------------------
584
585 /**
586 * Truncate statement
587 *
588 * Generates a platform-specific truncate string from the supplied data
589 * If the database does not support the truncate() command
590 * This function maps to "DELETE FROM table"
591 *
592 * @access public
593 * @param string the table name
594 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200595 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000596 function _truncate($table)
597 {
598 return "TRUNCATE ".$table;
599 }
Barry Mienydd671972010-10-04 16:33:58 +0200600
Derek Allard2067d1a2008-11-13 22:59:24 +0000601 // --------------------------------------------------------------------
602
603 /**
604 * Delete statement
605 *
606 * Generates a platform-specific delete string from the supplied data
607 *
608 * @access public
609 * @param string the table name
610 * @param array the where clause
611 * @param string the limit clause
612 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200613 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000614 function _delete($table, $where = array(), $like = array(), $limit = FALSE)
615 {
616 $conditions = '';
617
618 if (count($where) > 0 OR count($like) > 0)
619 {
620 $conditions = "\nWHERE ";
621 $conditions .= implode("\n", $this->ar_where);
622
623 if (count($where) > 0 && count($like) > 0)
624 {
625 $conditions .= " AND ";
626 }
627 $conditions .= implode("\n", $like);
628 }
629
630 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200631
Derek Allard2067d1a2008-11-13 22:59:24 +0000632 return "DELETE FROM ".$table.$conditions.$limit;
633 }
634
635 // --------------------------------------------------------------------
636
637 /**
638 * Limit string
639 *
640 * Generates a platform-specific LIMIT clause
641 *
642 * @access public
643 * @param string the sql query string
644 * @param integer the number of rows to limit the query to
645 * @param integer the offset value
646 * @return string
647 */
648 function _limit($sql, $limit, $offset)
649 {
650 $i = $limit + $offset;
Barry Mienydd671972010-10-04 16:33:58 +0200651
652 return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
Derek Allard2067d1a2008-11-13 22:59:24 +0000653 }
654
655 // --------------------------------------------------------------------
656
657 /**
658 * Close DB Connection
659 *
660 * @access public
661 * @param resource
662 * @return void
663 */
664 function _close($conn_id)
665 {
666 @mssql_close($conn_id);
Barry Mienydd671972010-10-04 16:33:58 +0200667 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000668
669}
670
671
672
673/* End of file mssql_driver.php */
Andrey Andreev11454e02012-02-22 16:05:47 +0200674/* Location: ./system/database/drivers/mssql/mssql_driver.php */