blob: 875f148a18fddf7505ac263c9ab4f734c667d71f [file] [log] [blame]
Andrey Andreevc5536aa2012-11-01 17:33:58 +02001<?php
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
Andrey Andreev80500af2013-01-01 08:16:53 +020021 * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
Timothy Warren7221f942012-02-14 15:02:33 -050022 * @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 */
Andrey Andreevc5536aa2012-11-01 17:33:58 +020027defined('BASEPATH') OR exit('No direct script access allowed');
Timothy Warren76e04352012-02-14 11:55:17 -050028
Timothy Warren76e04352012-02-14 11:55:17 -050029/**
30 * Firebird/Interbase Database Adapter Class
31 *
32 * Note: _DB is an extender class that the app controller
Jamie Rumbelowffe7a0a2012-04-26 13:48:18 +010033 * creates dynamically based on whether the query builder
Timothy Warren76e04352012-02-14 11:55:17 -050034 * class is being used or not.
35 *
Timothy Warren7221f942012-02-14 15:02:33 -050036 * @package CodeIgniter
37 * @subpackage Drivers
38 * @category Database
39 * @author EllisLab Dev Team
40 * @link http://codeigniter.com/user_guide/database/
Timothy Warren76e04352012-02-14 11:55:17 -050041 */
Andrey Andreev26086872012-07-05 11:21:58 +030042class CI_DB_ibase_driver extends CI_DB {
Timothy Warren76e04352012-02-14 11:55:17 -050043
Andrey Andreeva24e52e2012-11-02 03:54:12 +020044 /**
45 * Database driver
46 *
47 * @var string
48 */
Andrey Andreev26086872012-07-05 11:21:58 +030049 public $dbdriver = 'ibase';
Timothy Warren76e04352012-02-14 11:55:17 -050050
Andrey Andreeva24e52e2012-11-02 03:54:12 +020051 // --------------------------------------------------------------------
Timothy Warren76e04352012-02-14 11:55:17 -050052
Andrey Andreeva24e52e2012-11-02 03:54:12 +020053 /**
54 * ORDER BY random keyword
55 *
Andrey Andreev98e46cf2012-11-13 03:01:42 +020056 * @var array
Andrey Andreeva24e52e2012-11-02 03:54:12 +020057 */
Andrey Andreev98e46cf2012-11-13 03:01:42 +020058 protected $_random_keyword = array('RAND()', 'RAND()');
Andrey Andreev00df2e32012-03-02 18:37:16 +020059
Andrey Andreeva24e52e2012-11-02 03:54:12 +020060 /**
61 * IBase Transaction status flag
62 *
63 * @var resource
64 */
65 protected $_ibase_trans;
66
67 // --------------------------------------------------------------------
Timothy Warren76e04352012-02-14 11:55:17 -050068
69 /**
70 * Non-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_connect()
Timothy Warren76e04352012-02-14 11:55:17 -050075 {
Timothy Warren3c4281f2012-02-16 19:00:10 -050076 return @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
Timothy Warren76e04352012-02-14 11:55:17 -050077 }
78
79 // --------------------------------------------------------------------
80
81 /**
82 * Persistent database connection
83 *
Timothy Warren7221f942012-02-14 15:02:33 -050084 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050085 */
Timothy Warren4be822b2012-02-14 12:07:34 -050086 public function db_pconnect()
Timothy Warren76e04352012-02-14 11:55:17 -050087 {
Timothy Warren3c4281f2012-02-16 19:00:10 -050088 return @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
Timothy Warren76e04352012-02-14 11:55:17 -050089 }
90
91 // --------------------------------------------------------------------
92
93 /**
Andrey Andreev08856b82012-03-03 03:19:28 +020094 * Database version number
Timothy Warren76e04352012-02-14 11:55:17 -050095 *
Timothy Warren7221f942012-02-14 15:02:33 -050096 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -050097 */
Andrey Andreev08856b82012-03-03 03:19:28 +020098 public function version()
Timothy Warren76e04352012-02-14 11:55:17 -050099 {
Andrey Andreev08856b82012-03-03 03:19:28 +0200100 if (isset($this->data_cache['version']))
101 {
102 return $this->data_cache['version'];
103 }
104
Timothy Warren3d985a12012-02-15 11:38:00 -0500105 if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
106 {
Andrey Andreev08856b82012-03-03 03:19:28 +0200107 $this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
Andrey Andreev00df2e32012-03-02 18:37:16 +0200108
Timothy Warrenab189e12012-02-22 10:34:23 -0500109 // Don't keep the service open
110 ibase_service_detach($service);
Andrey Andreev08856b82012-03-03 03:19:28 +0200111 return $this->data_cache['version'];
Timothy Warren3d985a12012-02-15 11:38:00 -0500112 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200113
Timothy Warren3d985a12012-02-15 11:38:00 -0500114 return FALSE;
Timothy Warren76e04352012-02-14 11:55:17 -0500115 }
116
117 // --------------------------------------------------------------------
118
119 /**
120 * Execute the query
121 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200122 * @param string $sql an SQL query
Timothy Warren7221f942012-02-14 15:02:33 -0500123 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500124 */
Timothy Warren95562142012-02-20 17:37:21 -0500125 protected function _execute($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500126 {
Timothy Warren7221f942012-02-14 15:02:33 -0500127 return @ibase_query($this->conn_id, $sql);
Timothy Warren76e04352012-02-14 11:55:17 -0500128 }
129
130 // --------------------------------------------------------------------
131
132 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500133 * Begin Transaction
134 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200135 * @param bool $test_mode
Timothy Warren7221f942012-02-14 15:02:33 -0500136 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500137 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500138 public function trans_begin($test_mode = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500139 {
Timothy Warren76e04352012-02-14 11:55:17 -0500140 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev131772c2012-03-20 23:35:03 +0200141 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500142 {
143 return TRUE;
144 }
145
146 // Reset the transaction failure flag.
147 // If the $test_mode flag is set to TRUE transactions will be rolled back
148 // even if the queries produce a successful result.
Andrey Andreev131772c2012-03-20 23:35:03 +0200149 $this->_trans_failure = ($test_mode === TRUE);
Timothy Warren76e04352012-02-14 11:55:17 -0500150
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200151 $this->_ibase_trans = @ibase_trans($this->conn_id);
Andrey Andreev00df2e32012-03-02 18:37:16 +0200152
Timothy Warren76e04352012-02-14 11:55:17 -0500153 return TRUE;
154 }
155
156 // --------------------------------------------------------------------
157
158 /**
159 * Commit Transaction
160 *
Timothy Warren7221f942012-02-14 15:02:33 -0500161 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500162 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500163 public function trans_commit()
Timothy Warren76e04352012-02-14 11:55:17 -0500164 {
Timothy Warren76e04352012-02-14 11:55:17 -0500165 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev131772c2012-03-20 23:35:03 +0200166 if ( ! $this->trans_enabled OR $this->_trans->depth > 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500167 {
168 return TRUE;
169 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200170
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200171 return @ibase_commit($this->_ibase_trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500172 }
173
174 // --------------------------------------------------------------------
175
176 /**
177 * Rollback Transaction
178 *
Timothy Warren7221f942012-02-14 15:02:33 -0500179 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500180 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500181 public function trans_rollback()
Timothy Warren76e04352012-02-14 11:55:17 -0500182 {
Timothy Warren76e04352012-02-14 11:55:17 -0500183 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev131772c2012-03-20 23:35:03 +0200184 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500185 {
186 return TRUE;
187 }
188
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200189 return @ibase_rollback($this->_ibase_trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500190 }
191
192 // --------------------------------------------------------------------
193
194 /**
195 * Escape String
196 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200197 * @param string $str
198 * @param bool $like Whether or not the string will be used in a LIKE condition
Timothy Warren7221f942012-02-14 15:02:33 -0500199 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500200 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500201 public function escape_str($str, $like = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500202 {
203 if (is_array($str))
204 {
205 foreach ($str as $key => $val)
206 {
207 $str[$key] = $this->escape_str($val, $like);
208 }
209
210 return $str;
211 }
212
213 // escape LIKE condition wildcards
214 if ($like === TRUE)
215 {
Andrey Andreev131772c2012-03-20 23:35:03 +0200216 return str_replace(array($this->_like_escape_chr, '%', '_'),
217 array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
218 $str);
Timothy Warren76e04352012-02-14 11:55:17 -0500219 }
220
221 return $str;
222 }
223
224 // --------------------------------------------------------------------
225
226 /**
227 * Affected Rows
228 *
Andrey Andreev131772c2012-03-20 23:35:03 +0200229 * @return int
Timothy Warren76e04352012-02-14 11:55:17 -0500230 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500231 public function affected_rows()
Timothy Warren76e04352012-02-14 11:55:17 -0500232 {
Timothy Warren7221f942012-02-14 15:02:33 -0500233 return @ibase_affected_rows($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500234 }
235
236 // --------------------------------------------------------------------
237
238 /**
239 * Insert ID
240 *
Andrey Andreev131772c2012-03-20 23:35:03 +0200241 * @param string $generator_name
242 * @param int $inc_by
243 * @return int
Timothy Warren76e04352012-02-14 11:55:17 -0500244 */
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300245 public function insert_id($generator_name, $inc_by = 0)
Timothy Warren76e04352012-02-14 11:55:17 -0500246 {
Timothy Warren07b660b2012-02-20 13:23:06 -0500247 //If a generator hasn't been used before it will return 0
Timothy Warrenfed2d1d2012-02-20 15:42:45 -0500248 return ibase_gen_id('"'.$generator_name.'"', $inc_by);
Timothy Warren76e04352012-02-14 11:55:17 -0500249 }
250
251 // --------------------------------------------------------------------
252
253 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500254 * List table query
255 *
256 * Generates a platform-specific query string so that the table names can be fetched
257 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200258 * @param bool $prefix_limit
Timothy Warren7221f942012-02-14 15:02:33 -0500259 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500260 */
Timothy Warren95562142012-02-20 17:37:21 -0500261 protected function _list_tables($prefix_limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500262 {
Andrey Andreev60c9c992012-03-20 23:46:09 +0200263 $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 -0500264
Alex Bilbie48a2baf2012-06-02 11:09:54 +0100265 if ($prefix_limit !== FALSE && $this->dbprefix !== '')
Timothy Warren76e04352012-02-14 11:55:17 -0500266 {
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300267 return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
268 .sprintf($this->_like_escape_str, $this->_like_escape_chr);
Timothy Warren76e04352012-02-14 11:55:17 -0500269 }
Andrey Andreev131772c2012-03-20 23:35:03 +0200270
Timothy Warren76e04352012-02-14 11:55:17 -0500271 return $sql;
272 }
273
274 // --------------------------------------------------------------------
275
276 /**
277 * Show column query
278 *
279 * Generates a platform-specific query string so that the column names can be fetched
280 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200281 * @param string $table
Timothy Warren7221f942012-02-14 15:02:33 -0500282 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500283 */
Timothy Warren95562142012-02-20 17:37:21 -0500284 protected function _list_columns($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500285 {
Andrey Andreev5382b1b2012-06-25 01:26:48 +0300286 return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
Timothy Warren76e04352012-02-14 11:55:17 -0500287 }
288
289 // --------------------------------------------------------------------
290
291 /**
Andrey Andreev02e7a9d2012-11-16 01:49:46 +0200292 * Returns an object with field data
Timothy Warren76e04352012-02-14 11:55:17 -0500293 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200294 * @param string $table
Andrey Andreev02e7a9d2012-11-16 01:49:46 +0200295 * @return array
Timothy Warren76e04352012-02-14 11:55:17 -0500296 */
Andrey Andreev02e7a9d2012-11-16 01:49:46 +0200297 public function field_data($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500298 {
Andrey Andreev02e7a9d2012-11-16 01:49:46 +0200299 if ($table === '')
300 {
301 return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
302 }
303
304 $sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name",
305 CASE "fields"."RDB$FIELD_TYPE"
306 WHEN 7 THEN \'SMALLINT\'
307 WHEN 8 THEN \'INTEGER\'
308 WHEN 9 THEN \'QUAD\'
309 WHEN 10 THEN \'FLOAT\'
310 WHEN 11 THEN \'DFLOAT\'
311 WHEN 12 THEN \'DATE\'
312 WHEN 13 THEN \'TIME\'
313 WHEN 14 THEN \'CHAR\'
314 WHEN 16 THEN \'INT64\'
315 WHEN 27 THEN \'DOUBLE\'
316 WHEN 35 THEN \'TIMESTAMP\'
317 WHEN 37 THEN \'VARCHAR\'
318 WHEN 40 THEN \'CSTRING\'
319 WHEN 261 THEN \'BLOB\'
320 ELSE NULL
321 END AS "type",
322 "fields"."RDB$FIELD_LENGTH" AS "max_length",
323 "rfields"."RDB$DEFAULT_VALUE" AS "default"
324 FROM "RDB$RELATION_FIELDS" "rfields"
325 JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME"
326 WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).'
327 ORDER BY "rfields"."RDB$FIELD_POSITION"';
328
329 return (($query = $this->query($sql)) !== FALSE)
330 ? $query->result_object()
331 : FALSE;
Timothy Warren76e04352012-02-14 11:55:17 -0500332 }
333
334 // --------------------------------------------------------------------
335
336 /**
Andrey Andreev00df2e32012-03-02 18:37:16 +0200337 * Error
Timothy Warren76e04352012-02-14 11:55:17 -0500338 *
Andrey Andreev00df2e32012-03-02 18:37:16 +0200339 * Returns an array containing code and message of the last
340 * database error that has occured.
Timothy Warren76e04352012-02-14 11:55:17 -0500341 *
Andrey Andreev00df2e32012-03-02 18:37:16 +0200342 * @return array
Timothy Warren76e04352012-02-14 11:55:17 -0500343 */
Andrey Andreev00df2e32012-03-02 18:37:16 +0200344 public function error()
Timothy Warren76e04352012-02-14 11:55:17 -0500345 {
Andrey Andreev00df2e32012-03-02 18:37:16 +0200346 return array('code' => ibase_errcode(), 'message' => ibase_errmsg());
Timothy Warren76e04352012-02-14 11:55:17 -0500347 }
348
349 // --------------------------------------------------------------------
350
351 /**
Timothy Warren76e04352012-02-14 11:55:17 -0500352 * Update statement
353 *
354 * Generates a platform-specific update string from the supplied data
355 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200356 * @param string $table
357 * @param array $values
Timothy Warren7221f942012-02-14 15:02:33 -0500358 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500359 */
Andrey Andreevb0478652012-07-18 15:34:46 +0300360 protected function _update($table, $values)
Timothy Warren76e04352012-02-14 11:55:17 -0500361 {
Andrey Andreevb0478652012-07-18 15:34:46 +0300362 $this->qb_limit = FALSE;
363 return parent::_update($table, $values);
Timothy Warren76e04352012-02-14 11:55:17 -0500364 }
365
Timothy Warren76e04352012-02-14 11:55:17 -0500366 // --------------------------------------------------------------------
367
368 /**
369 * Truncate statement
370 *
371 * Generates a platform-specific truncate string from the supplied data
Andrey Andreeva6fe36e2012-04-05 16:00:32 +0300372 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200373 * If the database does not support the TRUNCATE statement,
Andrey Andreeva6fe36e2012-04-05 16:00:32 +0300374 * then this method maps to 'DELETE FROM table'
Timothy Warren76e04352012-02-14 11:55:17 -0500375 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200376 * @param string $table
Timothy Warren7221f942012-02-14 15:02:33 -0500377 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500378 */
Timothy Warren95562142012-02-20 17:37:21 -0500379 protected function _truncate($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500380 {
Andrey Andreeva6fe36e2012-04-05 16:00:32 +0300381 return 'DELETE FROM '.$table;
Timothy Warren76e04352012-02-14 11:55:17 -0500382 }
383
384 // --------------------------------------------------------------------
385
386 /**
387 * Delete statement
388 *
389 * Generates a platform-specific delete string from the supplied data
390 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200391 * @param string $table
Timothy Warren7221f942012-02-14 15:02:33 -0500392 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500393 */
Andrey Andreevb0478652012-07-18 15:34:46 +0300394 protected function _delete($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500395 {
Andrey Andreevb0478652012-07-18 15:34:46 +0300396 $this->qb_limit = FALSE;
397 return parent::_delete($table);
Timothy Warren76e04352012-02-14 11:55:17 -0500398 }
399
400 // --------------------------------------------------------------------
401
402 /**
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200403 * LIMIT
Timothy Warren76e04352012-02-14 11:55:17 -0500404 *
405 * Generates a platform-specific LIMIT clause
406 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200407 * @param string $sql SQL Query
Timothy Warren7221f942012-02-14 15:02:33 -0500408 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500409 */
Andrey Andreevc9b924c2012-07-19 13:06:02 +0300410 protected function _limit($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500411 {
Timothy Warren56784f62012-02-29 11:58:20 -0500412 // Limit clause depends on if Interbase or Firebird
Andrey Andreev08856b82012-03-03 03:19:28 +0200413 if (stripos($this->version(), 'firebird') !== FALSE)
Timothy Warren56784f62012-02-29 11:58:20 -0500414 {
Andrey Andreevc9b924c2012-07-19 13:06:02 +0300415 $select = 'FIRST '.$this->qb_limit
416 .($this->qb_offset ? ' SKIP '.$this->qb_offset : '');
Timothy Warren56784f62012-02-29 11:58:20 -0500417 }
418 else
419 {
Andrey Andreev131772c2012-03-20 23:35:03 +0200420 $select = 'ROWS '
Andrey Andreevc9b924c2012-07-19 13:06:02 +0300421 .($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit);
Timothy Warren56784f62012-02-29 11:58:20 -0500422 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200423
Timothy Warrena5410872013-01-09 10:44:14 -0500424 return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1);
Timothy Warren76e04352012-02-14 11:55:17 -0500425 }
426
427 // --------------------------------------------------------------------
428
429 /**
430 * Close DB Connection
431 *
Timothy Warren7221f942012-02-14 15:02:33 -0500432 * @return void
Timothy Warren76e04352012-02-14 11:55:17 -0500433 */
Andrey Andreev79922c02012-05-23 12:27:17 +0300434 protected function _close()
Timothy Warren76e04352012-02-14 11:55:17 -0500435 {
Andrey Andreev79922c02012-05-23 12:27:17 +0300436 @ibase_close($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500437 }
Andrey Andreev00df2e32012-03-02 18:37:16 +0200438
Timothy Warren76e04352012-02-14 11:55:17 -0500439}
440
Andrey Andreev26086872012-07-05 11:21:58 +0300441/* End of file ibase_driver.php */
442/* Location: ./system/database/drivers/ibase/ibase_driver.php */