blob: a011f103d4949e31c92ac4dbb55126c190fde7fa [file] [log] [blame]
Timothy Warren76e04352012-02-14 11:55:17 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 5.1.6 or newer
6 *
7 * 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
Timothy Warren7221f942012-02-14 15:02:33 -050017 * licensing@ellislab.com so we can send you a copy immediately.
Timothy Warren76e04352012-02-14 11:55:17 -050018 *
Timothy Warren7221f942012-02-14 15:02:33 -050019 * @package CodeIgniter
20 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
23 * @link http://codeigniter.com
24 * @since Version 3.0
25 * @filesource
Timothy Warren76e04352012-02-14 11:55:17 -050026 */
27
28// ------------------------------------------------------------------------
29
Timothy Warren76e04352012-02-14 11:55:17 -050030/**
31 * Firebird/Interbase 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 *
Timothy Warren7221f942012-02-14 15:02:33 -050037 * @package CodeIgniter
38 * @subpackage Drivers
39 * @category Database
40 * @author EllisLab Dev Team
41 * @link http://codeigniter.com/user_guide/database/
Timothy Warren76e04352012-02-14 11:55:17 -050042 */
43class CI_DB_interbase_driver extends CI_DB {
44
45 public $dbdriver = 'interbase';
46
47 // The character used to escape with
48 public $_escape_char = '"';
49
50 // clause and character used for LIKE escape sequences
51 public $_like_escape_str = " ESCAPE '%s' ";
52 public $_like_escape_chr = '!';
53
54 /**
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 public $_count_string = "SELECT COUNT(*) AS ";
60 public $_random_keyword = ' Random()'; // database specific random keyword
61
62 // Keeps track of the resource for the current transaction
63 protected $trans;
64
65 /**
66 * Non-persistent database connection
67 *
Timothy Warren7221f942012-02-14 15:02:33 -050068 * @access private called by the base class
69 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050070 */
Timothy Warren4be822b2012-02-14 12:07:34 -050071 public function db_connect()
Timothy Warren76e04352012-02-14 11:55:17 -050072 {
Timothy Warren7221f942012-02-14 15:02:33 -050073 if ( ! $conn_id = @ibase_connect($this->database, $this->username, $this->password, $this->char_set))
Timothy Warren76e04352012-02-14 11:55:17 -050074 {
Timothy Warrend19e47a2012-02-14 23:40:40 -050075 log_message('error', $this->_error_message());
Timothy Warren76e04352012-02-14 11:55:17 -050076
77 if ($this->db_debug)
78 {
Timothy Warrend19e47a2012-02-14 23:40:40 -050079 $this->display_error($this->_error_message(), '', TRUE);
Timothy Warren76e04352012-02-14 11:55:17 -050080 }
81
82 return FALSE;
83 }
84
85 return $conn_id;
86 }
87
88 // --------------------------------------------------------------------
89
90 /**
91 * Persistent database connection
92 *
Timothy Warren7221f942012-02-14 15:02:33 -050093 * @access private called by the base class
94 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050095 */
Timothy Warren4be822b2012-02-14 12:07:34 -050096 public function db_pconnect()
Timothy Warren76e04352012-02-14 11:55:17 -050097 {
Timothy Warren7221f942012-02-14 15:02:33 -050098 if ( ! $conn_id = @ibase_pconnect($this->database, $this->username, $this->password, $this->char_set))
Timothy Warren76e04352012-02-14 11:55:17 -050099 {
Timothy Warrend19e47a2012-02-14 23:40:40 -0500100 log_message('error', $this->_error_message());
Timothy Warren76e04352012-02-14 11:55:17 -0500101
102 if ($this->db_debug)
103 {
Timothy Warrend19e47a2012-02-14 23:40:40 -0500104 $this->display_error($this->_error_message(), '', TRUE);
Timothy Warren76e04352012-02-14 11:55:17 -0500105 }
106
107 return FALSE;
108 }
109
110 return $conn_id;
111 }
112
113 // --------------------------------------------------------------------
114
115 /**
116 * Reconnect
117 *
118 * Keep / reestablish the db connection if no queries have been
119 * sent for a length of time exceeding the server's idle timeout
120 *
Timothy Warren7221f942012-02-14 15:02:33 -0500121 * @access public
122 * @return void
Timothy Warren76e04352012-02-14 11:55:17 -0500123 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500124 public function reconnect()
Timothy Warren76e04352012-02-14 11:55:17 -0500125 {
126 // not implemented in Interbase/Firebird
127 }
128
129 // --------------------------------------------------------------------
130
131 /**
132 * Select the database
133 *
Timothy Warren7221f942012-02-14 15:02:33 -0500134 * @access private called by the base class
135 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500136 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500137 public function db_select()
Timothy Warren76e04352012-02-14 11:55:17 -0500138 {
139 // Connection selects the database
140 return TRUE;
141 }
142
143 // --------------------------------------------------------------------
144
145 /**
146 * Set client character set
147 *
Timothy Warren7221f942012-02-14 15:02:33 -0500148 * @access public
149 * @param string
150 * @param string
151 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500152 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500153 public function db_set_charset($charset, $collation)
Timothy Warren76e04352012-02-14 11:55:17 -0500154 {
Timothy Warren7221f942012-02-14 15:02:33 -0500155 // @todo - add support if needed
Timothy Warren76e04352012-02-14 11:55:17 -0500156 return TRUE;
157 }
158
159 // --------------------------------------------------------------------
160
161 /**
162 * Version number query string
163 *
Timothy Warren7221f942012-02-14 15:02:33 -0500164 * @access public
165 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500166 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500167 public function _version()
Timothy Warren76e04352012-02-14 11:55:17 -0500168 {
Timothy Warren7221f942012-02-14 15:02:33 -0500169 //@todo - add support if needed
Timothy Warren76e04352012-02-14 11:55:17 -0500170 return TRUE;
171 }
172
173 // --------------------------------------------------------------------
174
175 /**
176 * Execute the query
177 *
Timothy Warren7221f942012-02-14 15:02:33 -0500178 * @access private called by the base class
179 * @param string an SQL query
180 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500181 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500182 public function _execute($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500183 {
184 $sql = $this->_prep_query($sql);
Timothy Warren7221f942012-02-14 15:02:33 -0500185 return @ibase_query($this->conn_id, $sql);
Timothy Warren76e04352012-02-14 11:55:17 -0500186 }
187
188 // --------------------------------------------------------------------
189
190 /**
191 * Prep the query
192 *
193 * If needed, each database adapter can prep the query string
194 *
Timothy Warren7221f942012-02-14 15:02:33 -0500195 * @access private called by execute()
196 * @param string an SQL query
197 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500198 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500199 public function _prep_query($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500200 {
201 return $sql;
202 }
203
204 // --------------------------------------------------------------------
205
206 /**
207 * Begin Transaction
208 *
Timothy Warren7221f942012-02-14 15:02:33 -0500209 * @access public
210 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500211 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500212 public function trans_begin($test_mode = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500213 {
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 // Reset the transaction failure flag.
226 // If the $test_mode flag is set to TRUE transactions will be rolled back
227 // even if the queries produce a successful result.
228 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
229
Timothy Warren7221f942012-02-14 15:02:33 -0500230 $this->trans = @ibase_trans($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500231
232 return TRUE;
233 }
234
235 // --------------------------------------------------------------------
236
237 /**
238 * Commit Transaction
239 *
Timothy Warren7221f942012-02-14 15:02:33 -0500240 * @access public
241 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500242 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500243 public function trans_commit()
Timothy Warren76e04352012-02-14 11:55:17 -0500244 {
245 if ( ! $this->trans_enabled)
246 {
247 return TRUE;
248 }
249
250 // When transactions are nested we only begin/commit/rollback the outermost ones
251 if ($this->_trans_depth > 0)
252 {
253 return TRUE;
254 }
255
Timothy Warren7221f942012-02-14 15:02:33 -0500256 @ibase_commit($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500257
258 return TRUE;
259 }
260
261 // --------------------------------------------------------------------
262
263 /**
264 * Rollback Transaction
265 *
Timothy Warren7221f942012-02-14 15:02:33 -0500266 * @access public
267 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500268 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500269 public function trans_rollback()
Timothy Warren76e04352012-02-14 11:55:17 -0500270 {
271 if ( ! $this->trans_enabled)
272 {
273 return TRUE;
274 }
275
276 // When transactions are nested we only begin/commit/rollback the outermost ones
277 if ($this->_trans_depth > 0)
278 {
279 return TRUE;
280 }
281
Timothy Warren7221f942012-02-14 15:02:33 -0500282 @ibase_rollback($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500283
284 return TRUE;
285 }
286
287 // --------------------------------------------------------------------
288
289 /**
290 * Escape String
291 *
Timothy Warren7221f942012-02-14 15:02:33 -0500292 * @access public
293 * @param string
294 * @param bool whether or not the string will be used in a LIKE condition
295 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500296 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500297 public function escape_str($str, $like = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500298 {
299 if (is_array($str))
300 {
301 foreach ($str as $key => $val)
302 {
303 $str[$key] = $this->escape_str($val, $like);
304 }
305
306 return $str;
307 }
308
309 // escape LIKE condition wildcards
310 if ($like === TRUE)
311 {
312 $str = str_replace( array('%', '_', $this->_like_escape_chr),
313 array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
314 $str);
315 }
316
317 return $str;
318 }
319
320 // --------------------------------------------------------------------
321
322 /**
323 * Affected Rows
324 *
Timothy Warren7221f942012-02-14 15:02:33 -0500325 * @access public
326 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500327 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500328 public function affected_rows()
Timothy Warren76e04352012-02-14 11:55:17 -0500329 {
Timothy Warren7221f942012-02-14 15:02:33 -0500330 return @ibase_affected_rows($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500331 }
332
333 // --------------------------------------------------------------------
334
335 /**
336 * Insert ID
337 *
Timothy Warren7221f942012-02-14 15:02:33 -0500338 * @access public
339 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500340 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500341 public function insert_id()
Timothy Warren76e04352012-02-14 11:55:17 -0500342 {
Timothy Warren7221f942012-02-14 15:02:33 -0500343 //@todo Implement manually
Timothy Warren76e04352012-02-14 11:55:17 -0500344 return 0;
345 }
346
347 // --------------------------------------------------------------------
348
349 /**
350 * "Count All" query
351 *
352 * Generates a platform-specific query string that counts all records in
353 * the specified database
354 *
Timothy Warren7221f942012-02-14 15:02:33 -0500355 * @access public
356 * @param string
357 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500358 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500359 public function count_all($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500360 {
361 if ($table == '')
362 {
363 return 0;
364 }
365
366 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
367
368 if ($query->num_rows() == 0)
369 {
370 return 0;
371 }
372
373 $row = $query->row();
374 $this->_reset_select();
375 return (int) $row->numrows;
376 }
377
378 // --------------------------------------------------------------------
379
380 /**
381 * List table query
382 *
383 * Generates a platform-specific query string so that the table names can be fetched
384 *
Timothy Warren7221f942012-02-14 15:02:33 -0500385 * @access private
386 * @param boolean
387 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500388 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500389 public function _list_tables($prefix_limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500390 {
391 $sql = <<<SQL
392 SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
393 WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
394 AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
395SQL;
396
397 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
398 {
399 $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
400 }
401 return $sql;
402 }
403
404 // --------------------------------------------------------------------
405
406 /**
407 * Show column query
408 *
409 * Generates a platform-specific query string so that the column names can be fetched
410 *
Timothy Warren7221f942012-02-14 15:02:33 -0500411 * @access public
412 * @param string the table name
413 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500414 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500415 public function _list_columns($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500416 {
417 // Not supported
418 return FALSE;
419 }
420
421 // --------------------------------------------------------------------
422
423 /**
424 * Field data query
425 *
426 * Generates a platform-specific query so that the column data can be retrieved
427 *
Timothy Warren7221f942012-02-14 15:02:33 -0500428 * @access public
429 * @param string the table name
430 * @return object
Timothy Warren76e04352012-02-14 11:55:17 -0500431 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500432 public function _field_data($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500433 {
434 return "SELECT * FROM ".$table." LIMIT 1";
435 }
436
437 // --------------------------------------------------------------------
438
439 /**
440 * The error message string
441 *
Timothy Warren7221f942012-02-14 15:02:33 -0500442 * @access private
443 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500444 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500445 public function _error_message()
Timothy Warren76e04352012-02-14 11:55:17 -0500446 {
447 return ibase_errmsg();
448 }
449
450 // --------------------------------------------------------------------
451
452 /**
453 * The error message number
454 *
Timothy Warren7221f942012-02-14 15:02:33 -0500455 * @access private
456 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500457 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500458 public function _error_number()
Timothy Warren76e04352012-02-14 11:55:17 -0500459 {
460 return ibase_errcode();
461 }
462
463 // --------------------------------------------------------------------
464
465 /**
466 * Escape the SQL Identifiers
467 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500468 * This public function escapes column and table names
Timothy Warren76e04352012-02-14 11:55:17 -0500469 *
Timothy Warren7221f942012-02-14 15:02:33 -0500470 * @access private
471 * @param string
472 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500473 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500474 public function _escape_identifiers($item)
Timothy Warren76e04352012-02-14 11:55:17 -0500475 {
476 foreach ($this->_reserved_identifiers as $id)
477 {
478 if (strpos($item, '.'.$id) !== FALSE)
479 {
480 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
481
482 // remove duplicates if the user already included the escape
483 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
484 }
485 }
486
487 if (strpos($item, '.') !== FALSE)
488 {
489 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
490 }
491 else
492 {
493 $str = $this->_escape_char.$item.$this->_escape_char;
494 }
495
496 // remove duplicates if the user already included the escape
Timothy Warrend19e47a2012-02-14 23:40:40 -0500497 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
Timothy Warren76e04352012-02-14 11:55:17 -0500498 }
499
500 // --------------------------------------------------------------------
501
502 /**
503 * From Tables
504 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500505 * This public function implicitly groups FROM tables so there is no confusion
Timothy Warren76e04352012-02-14 11:55:17 -0500506 * about operator precedence in harmony with SQL standards
507 *
Timothy Warren7221f942012-02-14 15:02:33 -0500508 * @access public
509 * @param type
510 * @return type
Timothy Warren76e04352012-02-14 11:55:17 -0500511 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500512 public function _from_tables($tables)
Timothy Warren76e04352012-02-14 11:55:17 -0500513 {
514 if ( ! is_array($tables))
515 {
516 $tables = array($tables);
517 }
518
Timothy Warrend19e47a2012-02-14 23:40:40 -0500519 return implode(', ', $tables);
Timothy Warren76e04352012-02-14 11:55:17 -0500520 }
521
522 // --------------------------------------------------------------------
523
524 /**
525 * Insert statement
526 *
527 * Generates a platform-specific insert string from the supplied data
528 *
Timothy Warren7221f942012-02-14 15:02:33 -0500529 * @access public
530 * @param string the table name
531 * @param array the insert keys
532 * @param array the insert values
533 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500534 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500535 public function _insert($table, $keys, $values)
Timothy Warren76e04352012-02-14 11:55:17 -0500536 {
Timothy Warrend19e47a2012-02-14 23:40:40 -0500537 return "INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
Timothy Warren76e04352012-02-14 11:55:17 -0500538 }
539
540 // --------------------------------------------------------------------
541
542 /**
543 * Update statement
544 *
545 * Generates a platform-specific update string from the supplied data
546 *
Timothy Warren7221f942012-02-14 15:02:33 -0500547 * @access public
548 * @param string the table name
549 * @param array the update data
550 * @param array the where clause
551 * @param array the orderby clause
552 * @param array the limit clause
553 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500554 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500555 public function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500556 {
557 foreach ($values as $key => $val)
558 {
559 $valstr[] = $key." = ".$val;
560 }
561
562 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
563
564 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
565
566 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
567
568 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
569
570 $sql .= $orderby.$limit;
571
572 return $sql;
573 }
574
575
576 // --------------------------------------------------------------------
577
578 /**
579 * Truncate statement
580 *
581 * Generates a platform-specific truncate string from the supplied data
582 * If the database does not support the truncate() command
Timothy Warren4be822b2012-02-14 12:07:34 -0500583 * This public function maps to "DELETE FROM table"
Timothy Warren76e04352012-02-14 11:55:17 -0500584 *
Timothy Warren7221f942012-02-14 15:02:33 -0500585 * @access public
586 * @param string the table name
587 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500588 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500589 public function _truncate($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500590 {
591 return $this->_delete($table);
592 }
593
594 // --------------------------------------------------------------------
595
596 /**
597 * Delete statement
598 *
599 * Generates a platform-specific delete string from the supplied data
600 *
Timothy Warren7221f942012-02-14 15:02:33 -0500601 * @access public
602 * @param string the table name
603 * @param array the where clause
604 * @param string the limit clause
605 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500606 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500607 public function _delete($table, $where = array(), $like = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500608 {
609 $conditions = '';
610
611 if (count($where) > 0 OR count($like) > 0)
612 {
613 $conditions = "\nWHERE ";
614 $conditions .= implode("\n", $this->ar_where);
615
616 if (count($where) > 0 && count($like) > 0)
617 {
618 $conditions .= " AND ";
619 }
620 $conditions .= implode("\n", $like);
621 }
622
623 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
624
625 return "DELETE FROM ".$table.$conditions.$limit;
626 }
627
628 // --------------------------------------------------------------------
629
630 /**
631 * Limit string
632 *
633 * Generates a platform-specific LIMIT clause
634 *
Timothy Warren7221f942012-02-14 15:02:33 -0500635 * @access public
636 * @param string the sql query string
637 * @param integer the number of rows to limit the query to
638 * @param integer the offset value
639 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500640 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500641 public function _limit($sql, $limit, $offset)
Timothy Warren76e04352012-02-14 11:55:17 -0500642 {
643 if ($offset == 0)
644 {
645 $offset = '';
646 }
647 else
648 {
649 $offset .= ", ";
650 }
651
652 return $sql."LIMIT ".$offset.$limit;
653 }
654
655 // --------------------------------------------------------------------
656
657 /**
658 * Close DB Connection
659 *
Timothy Warren7221f942012-02-14 15:02:33 -0500660 * @access public
661 * @param resource
662 * @return void
Timothy Warren76e04352012-02-14 11:55:17 -0500663 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500664 public function _close($conn_id)
Timothy Warren76e04352012-02-14 11:55:17 -0500665 {
Timothy Warren7221f942012-02-14 15:02:33 -0500666 @ibase_close($conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500667 }
Timothy Warren76e04352012-02-14 11:55:17 -0500668}
669
670
671/* End of file interbase_driver.php */
672/* Location: ./system/database/drivers/interbase/interbase_driver.php */