blob: c9027670d41d0dbe9830673c9345d41664c7ced2 [file] [log] [blame]
Timothy Warren817af192012-02-16 08:28:00 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Timothy Warren76e04352012-02-14 11:55:17 -05002/**
3 * CodeIgniter
4 *
Phil Sturgeon07c1ac82012-03-09 17:03:37 +00005 * An open source application development framework for PHP 5.2.4 or newer
Timothy Warren76e04352012-02-14 11:55:17 -05006 *
7 * NOTICE OF LICENSE
Timothy Warren817af192012-02-16 08:28:00 -05008 *
Timothy Warren76e04352012-02-14 11:55:17 -05009 * Licensed under the Open Software License version 3.0
Timothy Warren817af192012-02-16 08:28:00 -050010 *
Timothy Warren76e04352012-02-14 11:55:17 -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
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
Timothy Warren76e04352012-02-14 11:55:17 -050028/**
29 * Firebird/Interbase Database Adapter Class
30 *
31 * Note: _DB is an extender class that the app controller
Jamie Rumbelowffe7a0a2012-04-26 13:48:18 +010032 * creates dynamically based on whether the query builder
Timothy Warren76e04352012-02-14 11:55:17 -050033 * class is being used or not.
34 *
Timothy Warren7221f942012-02-14 15:02:33 -050035 * @package CodeIgniter
36 * @subpackage Drivers
37 * @category Database
38 * @author EllisLab Dev Team
39 * @link http://codeigniter.com/user_guide/database/
Timothy Warren76e04352012-02-14 11:55:17 -050040 */
Andrey Andreev26086872012-07-05 11:21:58 +030041class CI_DB_ibase_driver extends CI_DB {
Timothy Warren76e04352012-02-14 11:55:17 -050042
Andrey Andreev26086872012-07-05 11:21:58 +030043 public $dbdriver = 'ibase';
Timothy Warren76e04352012-02-14 11:55:17 -050044
45 // The character used to escape with
Timothy Warren95562142012-02-20 17:37:21 -050046 protected $_escape_char = '"';
Timothy Warren76e04352012-02-14 11:55:17 -050047
48 // clause and character used for LIKE escape sequences
Timothy Warren95562142012-02-20 17:37:21 -050049 protected $_like_escape_str = " ESCAPE '%s' ";
50 protected $_like_escape_chr = '!';
Timothy Warren76e04352012-02-14 11:55:17 -050051
Andrey Andreev77a5d942012-07-05 15:42:14 +030052 protected $_random_keyword = ' Random()'; // database specific random keyword
Andrey Andreev00df2e32012-03-02 18:37:16 +020053
Timothy Warren76e04352012-02-14 11:55:17 -050054 // Keeps track of the resource for the current transaction
55 protected $trans;
56
57 /**
58 * Non-persistent database connection
59 *
Timothy Warren7221f942012-02-14 15:02:33 -050060 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050061 */
Timothy Warren4be822b2012-02-14 12:07:34 -050062 public function db_connect()
Timothy Warren76e04352012-02-14 11:55:17 -050063 {
Timothy Warren3c4281f2012-02-16 19:00:10 -050064 return @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
Timothy Warren76e04352012-02-14 11:55:17 -050065 }
66
67 // --------------------------------------------------------------------
68
69 /**
70 * Persistent database connection
71 *
Timothy Warren7221f942012-02-14 15:02:33 -050072 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050073 */
Timothy Warren4be822b2012-02-14 12:07:34 -050074 public function db_pconnect()
Timothy Warren76e04352012-02-14 11:55:17 -050075 {
Timothy Warren3c4281f2012-02-16 19:00:10 -050076 return @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
Timothy Warren76e04352012-02-14 11:55:17 -050077 }
78
79 // --------------------------------------------------------------------
80
81 /**
Andrey Andreev08856b82012-03-03 03:19:28 +020082 * Database version number
Timothy Warren76e04352012-02-14 11:55:17 -050083 *
Timothy Warren7221f942012-02-14 15:02:33 -050084 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -050085 */
Andrey Andreev08856b82012-03-03 03:19:28 +020086 public function version()
Timothy Warren76e04352012-02-14 11:55:17 -050087 {
Andrey Andreev08856b82012-03-03 03:19:28 +020088 if (isset($this->data_cache['version']))
89 {
90 return $this->data_cache['version'];
91 }
92
Timothy Warren3d985a12012-02-15 11:38:00 -050093 if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
94 {
Andrey Andreev08856b82012-03-03 03:19:28 +020095 $this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
Andrey Andreev00df2e32012-03-02 18:37:16 +020096
Timothy Warrenab189e12012-02-22 10:34:23 -050097 // Don't keep the service open
98 ibase_service_detach($service);
Andrey Andreev08856b82012-03-03 03:19:28 +020099 return $this->data_cache['version'];
Timothy Warren3d985a12012-02-15 11:38:00 -0500100 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200101
Timothy Warren3d985a12012-02-15 11:38:00 -0500102 return FALSE;
Timothy Warren76e04352012-02-14 11:55:17 -0500103 }
104
105 // --------------------------------------------------------------------
106
107 /**
108 * Execute the query
109 *
Timothy Warren7221f942012-02-14 15:02:33 -0500110 * @param string an SQL query
111 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500112 */
Timothy Warren95562142012-02-20 17:37:21 -0500113 protected function _execute($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500114 {
Timothy Warren7221f942012-02-14 15:02:33 -0500115 return @ibase_query($this->conn_id, $sql);
Timothy Warren76e04352012-02-14 11:55:17 -0500116 }
117
118 // --------------------------------------------------------------------
119
120 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500121 * Begin Transaction
122 *
Timothy Warren7221f942012-02-14 15:02:33 -0500123 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500124 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500125 public function trans_begin($test_mode = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500126 {
Timothy Warren76e04352012-02-14 11:55:17 -0500127 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev131772c2012-03-20 23:35:03 +0200128 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500129 {
130 return TRUE;
131 }
132
133 // Reset the transaction failure flag.
134 // If the $test_mode flag is set to TRUE transactions will be rolled back
135 // even if the queries produce a successful result.
Andrey Andreev131772c2012-03-20 23:35:03 +0200136 $this->_trans_failure = ($test_mode === TRUE);
Timothy Warren76e04352012-02-14 11:55:17 -0500137
Timothy Warren7221f942012-02-14 15:02:33 -0500138 $this->trans = @ibase_trans($this->conn_id);
Andrey Andreev00df2e32012-03-02 18:37:16 +0200139
Timothy Warren76e04352012-02-14 11:55:17 -0500140 return TRUE;
141 }
142
143 // --------------------------------------------------------------------
144
145 /**
146 * Commit Transaction
147 *
Timothy Warren7221f942012-02-14 15:02:33 -0500148 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500149 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500150 public function trans_commit()
Timothy Warren76e04352012-02-14 11:55:17 -0500151 {
Timothy Warren76e04352012-02-14 11:55:17 -0500152 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev131772c2012-03-20 23:35:03 +0200153 if ( ! $this->trans_enabled OR $this->_trans->depth > 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500154 {
155 return TRUE;
156 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200157
Timothy Warren2062a862012-02-20 19:38:10 -0500158 return @ibase_commit($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500159 }
160
161 // --------------------------------------------------------------------
162
163 /**
164 * Rollback Transaction
165 *
Timothy Warren7221f942012-02-14 15:02:33 -0500166 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500167 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500168 public function trans_rollback()
Timothy Warren76e04352012-02-14 11:55:17 -0500169 {
Timothy Warren76e04352012-02-14 11:55:17 -0500170 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev131772c2012-03-20 23:35:03 +0200171 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500172 {
173 return TRUE;
174 }
175
Timothy Warren2062a862012-02-20 19:38:10 -0500176 return @ibase_rollback($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500177 }
178
179 // --------------------------------------------------------------------
180
181 /**
182 * Escape String
183 *
Timothy Warren7221f942012-02-14 15:02:33 -0500184 * @param string
185 * @param bool whether or not the string will be used in a LIKE condition
186 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500187 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500188 public function escape_str($str, $like = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500189 {
190 if (is_array($str))
191 {
192 foreach ($str as $key => $val)
193 {
194 $str[$key] = $this->escape_str($val, $like);
195 }
196
197 return $str;
198 }
199
200 // escape LIKE condition wildcards
201 if ($like === TRUE)
202 {
Andrey Andreev131772c2012-03-20 23:35:03 +0200203 return str_replace(array($this->_like_escape_chr, '%', '_'),
204 array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
205 $str);
Timothy Warren76e04352012-02-14 11:55:17 -0500206 }
207
208 return $str;
209 }
210
211 // --------------------------------------------------------------------
212
213 /**
214 * Affected Rows
215 *
Andrey Andreev131772c2012-03-20 23:35:03 +0200216 * @return int
Timothy Warren76e04352012-02-14 11:55:17 -0500217 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500218 public function affected_rows()
Timothy Warren76e04352012-02-14 11:55:17 -0500219 {
Timothy Warren7221f942012-02-14 15:02:33 -0500220 return @ibase_affected_rows($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500221 }
222
223 // --------------------------------------------------------------------
224
225 /**
226 * Insert ID
227 *
Andrey Andreev131772c2012-03-20 23:35:03 +0200228 * @param string $generator_name
229 * @param int $inc_by
230 * @return int
Timothy Warren76e04352012-02-14 11:55:17 -0500231 */
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300232 public function insert_id($generator_name, $inc_by = 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500233 {
Timothy Warren07b660b2012-02-20 13:23:06 -0500234 //If a generator hasn't been used before it will return 0
Timothy Warrenfed2d1d2012-02-20 15:42:45 -0500235 return ibase_gen_id('"'.$generator_name.'"', $inc_by);
Timothy Warren76e04352012-02-14 11:55:17 -0500236 }
237
238 // --------------------------------------------------------------------
239
240 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500241 * List table query
242 *
243 * Generates a platform-specific query string so that the table names can be fetched
244 *
Andrey Andreev131772c2012-03-20 23:35:03 +0200245 * @param bool
Timothy Warren7221f942012-02-14 15:02:33 -0500246 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500247 */
Timothy Warren95562142012-02-20 17:37:21 -0500248 protected function _list_tables($prefix_limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500249 {
Andrey Andreev60c9c992012-03-20 23:46:09 +0200250 $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
Timothy Warren76e04352012-02-14 11:55:17 -0500251
Alex Bilbie48a2baf2012-06-02 11:09:54 +0100252 if ($prefix_limit !== FALSE && $this->dbprefix !== '')
Timothy Warren76e04352012-02-14 11:55:17 -0500253 {
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300254 return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
255 .sprintf($this->_like_escape_str, $this->_like_escape_chr);
Timothy Warren76e04352012-02-14 11:55:17 -0500256 }
Andrey Andreev131772c2012-03-20 23:35:03 +0200257
Timothy Warren76e04352012-02-14 11:55:17 -0500258 return $sql;
259 }
260
261 // --------------------------------------------------------------------
262
263 /**
264 * Show column query
265 *
266 * Generates a platform-specific query string so that the column names can be fetched
267 *
Timothy Warren7221f942012-02-14 15:02:33 -0500268 * @param string the table name
269 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500270 */
Timothy Warren95562142012-02-20 17:37:21 -0500271 protected function _list_columns($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500272 {
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300273 return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
Timothy Warren76e04352012-02-14 11:55:17 -0500274 }
275
276 // --------------------------------------------------------------------
277
278 /**
279 * Field data query
280 *
281 * Generates a platform-specific query so that the column data can be retrieved
282 *
Timothy Warren7221f942012-02-14 15:02:33 -0500283 * @param string the table name
Andrey Andreev131772c2012-03-20 23:35:03 +0200284 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500285 */
Timothy Warren95562142012-02-20 17:37:21 -0500286 protected function _field_data($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500287 {
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300288 return $this->_limit('SELECT * FROM '.$this->protect_identifiers($table), 1, NULL);
Timothy Warren76e04352012-02-14 11:55:17 -0500289 }
290
291 // --------------------------------------------------------------------
292
293 /**
Andrey Andreev00df2e32012-03-02 18:37:16 +0200294 * Error
Timothy Warren76e04352012-02-14 11:55:17 -0500295 *
Andrey Andreev00df2e32012-03-02 18:37:16 +0200296 * Returns an array containing code and message of the last
297 * database error that has occured.
Timothy Warren76e04352012-02-14 11:55:17 -0500298 *
Andrey Andreev00df2e32012-03-02 18:37:16 +0200299 * @return array
Timothy Warren76e04352012-02-14 11:55:17 -0500300 */
Andrey Andreev00df2e32012-03-02 18:37:16 +0200301 public function error()
Timothy Warren76e04352012-02-14 11:55:17 -0500302 {
Andrey Andreev00df2e32012-03-02 18:37:16 +0200303 return array('code' => ibase_errcode(), 'message' => ibase_errmsg());
Timothy Warren76e04352012-02-14 11:55:17 -0500304 }
305
306 // --------------------------------------------------------------------
307
308 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500309 * From Tables
310 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500311 * This public function implicitly groups FROM tables so there is no confusion
Timothy Warren76e04352012-02-14 11:55:17 -0500312 * about operator precedence in harmony with SQL standards
313 *
Andrey Andreev131772c2012-03-20 23:35:03 +0200314 * @param array
315 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500316 */
Timothy Warren95562142012-02-20 17:37:21 -0500317 protected function _from_tables($tables)
Timothy Warren76e04352012-02-14 11:55:17 -0500318 {
Andrey Andreevc78e56a2012-06-08 02:12:07 +0300319 return is_array($tables) ? implode(', ', $tables) : $tables;
Timothy Warren76e04352012-02-14 11:55:17 -0500320 }
321
322 // --------------------------------------------------------------------
323
324 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500325 * Update statement
326 *
327 * Generates a platform-specific update string from the supplied data
328 *
Timothy Warren7221f942012-02-14 15:02:33 -0500329 * @param string the table name
330 * @param array the update data
331 * @param array the where clause
332 * @param array the orderby clause
Andrey Andreev00541ae2012-04-09 11:43:10 +0300333 * @param array the limit clause (ignored)
334 * @param array the like clause
Timothy Warren7221f942012-02-14 15:02:33 -0500335 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500336 */
Andrey Andreev00541ae2012-04-09 11:43:10 +0300337 protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
Timothy Warren76e04352012-02-14 11:55:17 -0500338 {
339 foreach ($values as $key => $val)
340 {
Andrey Andreev131772c2012-03-20 23:35:03 +0200341 $valstr[] = $key.' = '.$val;
Timothy Warren76e04352012-02-14 11:55:17 -0500342 }
343
Andrey Andreev00541ae2012-04-09 11:43:10 +0300344 $where = empty($where) ? '' : ' WHERE '.implode(' ', $where);
345
346 if ( ! empty($like))
347 {
348 $where .= ($where === '' ? ' WHERE ' : ' AND ').implode(' ', $like);
349 }
Timothy Warren76e04352012-02-14 11:55:17 -0500350
Andrey Andreev131772c2012-03-20 23:35:03 +0200351 return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
Andrey Andreev00541ae2012-04-09 11:43:10 +0300352 .$where
Andrey Andreev131772c2012-03-20 23:35:03 +0200353 .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '');
Timothy Warren76e04352012-02-14 11:55:17 -0500354 }
355
Timothy Warren76e04352012-02-14 11:55:17 -0500356 // --------------------------------------------------------------------
357
358 /**
359 * Truncate statement
360 *
361 * Generates a platform-specific truncate string from the supplied data
Andrey Andreeva6fe36e2012-04-05 16:00:32 +0300362 *
363 * If the database does not support the truncate() command,
364 * then this method maps to 'DELETE FROM table'
Timothy Warren76e04352012-02-14 11:55:17 -0500365 *
Timothy Warren7221f942012-02-14 15:02:33 -0500366 * @param string the table name
367 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500368 */
Timothy Warren95562142012-02-20 17:37:21 -0500369 protected function _truncate($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500370 {
Andrey Andreeva6fe36e2012-04-05 16:00:32 +0300371 return 'DELETE FROM '.$table;
Timothy Warren76e04352012-02-14 11:55:17 -0500372 }
373
374 // --------------------------------------------------------------------
375
376 /**
377 * Delete statement
378 *
379 * Generates a platform-specific delete string from the supplied data
380 *
Timothy Warren7221f942012-02-14 15:02:33 -0500381 * @param string the table name
382 * @param array the where clause
Andrey Andreevc01d3162012-04-09 12:55:11 +0300383 * @param array the like clause
Andrey Andreeva2548362012-04-09 13:03:11 +0300384 * @param string the limit clause (ignored)
Timothy Warren7221f942012-02-14 15:02:33 -0500385 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500386 */
Andrey Andreeva2548362012-04-09 13:03:11 +0300387 protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500388 {
Andrey Andreevc01d3162012-04-09 12:55:11 +0300389 $conditions = array();
Timothy Warren76e04352012-02-14 11:55:17 -0500390
Andrey Andreevc01d3162012-04-09 12:55:11 +0300391 empty($where) OR $conditions[] = implode(' ', $where);
392 empty($like) OR $conditions[] = implode(' ', $like);
Timothy Warren76e04352012-02-14 11:55:17 -0500393
Andrey Andreevc01d3162012-04-09 12:55:11 +0300394 return 'DELETE FROM '.$table.(count($conditions) > 0 ? ' WHERE '.implode(' AND ', $conditions) : '');
Timothy Warren76e04352012-02-14 11:55:17 -0500395 }
396
397 // --------------------------------------------------------------------
398
399 /**
400 * Limit string
401 *
402 * Generates a platform-specific LIMIT clause
403 *
Timothy Warren7221f942012-02-14 15:02:33 -0500404 * @param string the sql query string
Andrey Andreev131772c2012-03-20 23:35:03 +0200405 * @param int the number of rows to limit the query to
406 * @param int the offset value
Timothy Warren7221f942012-02-14 15:02:33 -0500407 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500408 */
Timothy Warren95562142012-02-20 17:37:21 -0500409 protected function _limit($sql, $limit, $offset)
Timothy Warren76e04352012-02-14 11:55:17 -0500410 {
Timothy Warren56784f62012-02-29 11:58:20 -0500411 // Limit clause depends on if Interbase or Firebird
Andrey Andreev08856b82012-03-03 03:19:28 +0200412 if (stripos($this->version(), 'firebird') !== FALSE)
Timothy Warren56784f62012-02-29 11:58:20 -0500413 {
Andrey Andreev131772c2012-03-20 23:35:03 +0200414 $select = 'FIRST '. (int) $limit
Andrey Andreev2c35b642012-06-24 03:05:26 +0300415 .($offset ? ' SKIP '. (int) $offset : '');
Timothy Warren56784f62012-02-29 11:58:20 -0500416 }
417 else
418 {
Andrey Andreev131772c2012-03-20 23:35:03 +0200419 $select = 'ROWS '
Andrey Andreev2c35b642012-06-24 03:05:26 +0300420 .($offset ? (int) $offset.' TO '.($limit + $offset) : (int) $limit);
Timothy Warren56784f62012-02-29 11:58:20 -0500421 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200422
Andrey Andreev131772c2012-03-20 23:35:03 +0200423 return preg_replace('`SELECT`i', 'SELECT '.$select, $sql);
Timothy Warren76e04352012-02-14 11:55:17 -0500424 }
425
426 // --------------------------------------------------------------------
427
428 /**
429 * Close DB Connection
430 *
Timothy Warren7221f942012-02-14 15:02:33 -0500431 * @return void
Timothy Warren76e04352012-02-14 11:55:17 -0500432 */
Andrey Andreev79922c02012-05-23 12:27:17 +0300433 protected function _close()
Timothy Warren76e04352012-02-14 11:55:17 -0500434 {
Andrey Andreev79922c02012-05-23 12:27:17 +0300435 @ibase_close($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500436 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200437
Timothy Warren76e04352012-02-14 11:55:17 -0500438}
439
Andrey Andreev26086872012-07-05 11:21:58 +0300440/* End of file ibase_driver.php */
441/* Location: ./system/database/drivers/ibase/ibase_driver.php */