blob: fcefa6d972b8161b1f5637ea9f6519a56a98f746 [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 *
5 * An open source application development framework for PHP 5.1.6 or newer
6 *
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
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 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050069 */
Timothy Warren4be822b2012-02-14 12:07:34 -050070 public function db_connect()
Timothy Warren76e04352012-02-14 11:55:17 -050071 {
Timothy Warren3c4281f2012-02-16 19:00:10 -050072 return @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
Timothy Warren76e04352012-02-14 11:55:17 -050073 }
74
75 // --------------------------------------------------------------------
76
77 /**
78 * Persistent database connection
79 *
Timothy Warren7221f942012-02-14 15:02:33 -050080 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -050081 */
Timothy Warren4be822b2012-02-14 12:07:34 -050082 public function db_pconnect()
Timothy Warren76e04352012-02-14 11:55:17 -050083 {
Timothy Warren3c4281f2012-02-16 19:00:10 -050084 return @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
Timothy Warren76e04352012-02-14 11:55:17 -050085 }
86
87 // --------------------------------------------------------------------
88
89 /**
90 * Reconnect
91 *
92 * Keep / reestablish the db connection if no queries have been
93 * sent for a length of time exceeding the server's idle timeout
94 *
Timothy Warren7221f942012-02-14 15:02:33 -050095 * @return void
Timothy Warren76e04352012-02-14 11:55:17 -050096 */
Timothy Warren4be822b2012-02-14 12:07:34 -050097 public function reconnect()
Timothy Warren76e04352012-02-14 11:55:17 -050098 {
99 // not implemented in Interbase/Firebird
100 }
101
102 // --------------------------------------------------------------------
103
104 /**
105 * Select the database
106 *
Timothy Warrenc2b712e2012-02-17 15:58:08 -0500107 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500108 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500109 public function db_select()
Timothy Warren76e04352012-02-14 11:55:17 -0500110 {
111 // Connection selects the database
112 return TRUE;
113 }
114
115 // --------------------------------------------------------------------
116
117 /**
118 * Set client character set
119 *
Timothy Warren7221f942012-02-14 15:02:33 -0500120 * @param string
121 * @param string
Timothy Warrenc2b712e2012-02-17 15:58:08 -0500122 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500123 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500124 public function db_set_charset($charset, $collation)
Timothy Warren76e04352012-02-14 11:55:17 -0500125 {
Timothy Warren3d985a12012-02-15 11:38:00 -0500126 // Must be determined at connection
Timothy Warren76e04352012-02-14 11:55:17 -0500127 return TRUE;
128 }
129
130 // --------------------------------------------------------------------
131
132 /**
133 * Version number query string
134 *
Timothy Warren7221f942012-02-14 15:02:33 -0500135 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500136 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500137 public function _version()
Timothy Warren76e04352012-02-14 11:55:17 -0500138 {
Timothy Warren3d985a12012-02-15 11:38:00 -0500139 if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
140 {
141 $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
142 return $version;
143 }
144
145 return FALSE;
Timothy Warren76e04352012-02-14 11:55:17 -0500146 }
147
148 // --------------------------------------------------------------------
149
150 /**
151 * Execute the query
152 *
Timothy Warren7221f942012-02-14 15:02:33 -0500153 * @param string an SQL query
154 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500155 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500156 public function _execute($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500157 {
158 $sql = $this->_prep_query($sql);
Timothy Warren7221f942012-02-14 15:02:33 -0500159 return @ibase_query($this->conn_id, $sql);
Timothy Warren76e04352012-02-14 11:55:17 -0500160 }
161
162 // --------------------------------------------------------------------
163
164 /**
165 * Prep the query
166 *
167 * If needed, each database adapter can prep the query string
168 *
Timothy Warren7221f942012-02-14 15:02:33 -0500169 * @param string an SQL query
170 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500171 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500172 public function _prep_query($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500173 {
174 return $sql;
175 }
176
177 // --------------------------------------------------------------------
178
179 /**
180 * Begin Transaction
181 *
Timothy Warren7221f942012-02-14 15:02:33 -0500182 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500183 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500184 public function trans_begin($test_mode = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500185 {
186 if ( ! $this->trans_enabled)
187 {
188 return TRUE;
189 }
190
191 // When transactions are nested we only begin/commit/rollback the outermost ones
192 if ($this->_trans_depth > 0)
193 {
194 return TRUE;
195 }
196
197 // Reset the transaction failure flag.
198 // If the $test_mode flag is set to TRUE transactions will be rolled back
199 // even if the queries produce a successful result.
200 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
201
Timothy Warren7221f942012-02-14 15:02:33 -0500202 $this->trans = @ibase_trans($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500203
204 return TRUE;
205 }
206
207 // --------------------------------------------------------------------
208
209 /**
210 * Commit Transaction
211 *
Timothy Warren7221f942012-02-14 15:02:33 -0500212 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500213 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500214 public function trans_commit()
Timothy Warren76e04352012-02-14 11:55:17 -0500215 {
216 if ( ! $this->trans_enabled)
217 {
218 return TRUE;
219 }
220
221 // When transactions are nested we only begin/commit/rollback the outermost ones
222 if ($this->_trans_depth > 0)
223 {
224 return TRUE;
225 }
226
Timothy Warren7221f942012-02-14 15:02:33 -0500227 @ibase_commit($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500228
229 return TRUE;
230 }
231
232 // --------------------------------------------------------------------
233
234 /**
235 * Rollback Transaction
236 *
Timothy Warren7221f942012-02-14 15:02:33 -0500237 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500238 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500239 public function trans_rollback()
Timothy Warren76e04352012-02-14 11:55:17 -0500240 {
241 if ( ! $this->trans_enabled)
242 {
243 return TRUE;
244 }
245
246 // When transactions are nested we only begin/commit/rollback the outermost ones
247 if ($this->_trans_depth > 0)
248 {
249 return TRUE;
250 }
251
Timothy Warren7221f942012-02-14 15:02:33 -0500252 @ibase_rollback($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500253
254 return TRUE;
255 }
256
257 // --------------------------------------------------------------------
258
259 /**
260 * Escape String
261 *
Timothy Warren7221f942012-02-14 15:02:33 -0500262 * @param string
263 * @param bool whether or not the string will be used in a LIKE condition
264 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500265 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500266 public function escape_str($str, $like = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500267 {
268 if (is_array($str))
269 {
270 foreach ($str as $key => $val)
271 {
272 $str[$key] = $this->escape_str($val, $like);
273 }
274
275 return $str;
276 }
277
278 // escape LIKE condition wildcards
279 if ($like === TRUE)
280 {
281 $str = str_replace( array('%', '_', $this->_like_escape_chr),
282 array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
283 $str);
284 }
285
286 return $str;
287 }
288
289 // --------------------------------------------------------------------
290
291 /**
292 * Affected Rows
293 *
Timothy Warren7221f942012-02-14 15:02:33 -0500294 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500295 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500296 public function affected_rows()
Timothy Warren76e04352012-02-14 11:55:17 -0500297 {
Timothy Warren7221f942012-02-14 15:02:33 -0500298 return @ibase_affected_rows($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500299 }
300
301 // --------------------------------------------------------------------
302
303 /**
304 * Insert ID
305 *
Timothy Warren6e821ce2012-02-15 18:40:39 -0500306 * @param string $generator_name
307 * @param integer $inc_by
Timothy Warren7221f942012-02-14 15:02:33 -0500308 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500309 */
Timothy Warren817af192012-02-16 08:28:00 -0500310 public function insert_id($generator_name, $inc_by=0)
Timothy Warren76e04352012-02-14 11:55:17 -0500311 {
Timothy Warren53e24f02012-02-20 11:55:31 -0500312 return ibase_gen_id('"'.$generator_name.'"', $inc_by);
Timothy Warren76e04352012-02-14 11:55:17 -0500313 }
314
315 // --------------------------------------------------------------------
316
317 /**
318 * "Count All" query
319 *
320 * Generates a platform-specific query string that counts all records in
321 * the specified database
322 *
Timothy Warren7221f942012-02-14 15:02:33 -0500323 * @param string
324 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500325 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500326 public function count_all($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500327 {
328 if ($table == '')
329 {
330 return 0;
331 }
332
Timothy Warren817af192012-02-16 08:28:00 -0500333 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . ' FROM ' . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
Timothy Warren76e04352012-02-14 11:55:17 -0500334
Timothy Warrenc2b712e2012-02-17 15:58:08 -0500335 $query->result_array();
336
Timothy Warren76e04352012-02-14 11:55:17 -0500337 if ($query->num_rows() == 0)
338 {
339 return 0;
340 }
341
342 $row = $query->row();
343 $this->_reset_select();
344 return (int) $row->numrows;
345 }
346
347 // --------------------------------------------------------------------
348
349 /**
350 * List table query
351 *
352 * Generates a platform-specific query string so that the table names can be fetched
353 *
Timothy Warren7221f942012-02-14 15:02:33 -0500354 * @param boolean
355 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500356 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500357 public function _list_tables($prefix_limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500358 {
359 $sql = <<<SQL
360 SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
361 WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
362 AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
363SQL;
364
365 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
366 {
Timothy Warren3d985a12012-02-15 11:38:00 -0500367 $sql .= ' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
Timothy Warren76e04352012-02-14 11:55:17 -0500368 }
369 return $sql;
370 }
371
372 // --------------------------------------------------------------------
373
374 /**
375 * Show column query
376 *
377 * Generates a platform-specific query string so that the column names can be fetched
378 *
Timothy Warren7221f942012-02-14 15:02:33 -0500379 * @param string the table name
380 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500381 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500382 public function _list_columns($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500383 {
Timothy Warrenc2b712e2012-02-17 15:58:08 -0500384 return <<<SQL
Timothy Warreneb6dcf02012-02-15 16:48:51 -0500385 SELECT "RDB\$FIELD_NAME" FROM "RDB\$RELATION_FIELDS"
Timothy Warrenc2b712e2012-02-17 15:58:08 -0500386 WHERE "RDB\$RELATION_NAME"='{$table}';
Timothy Warreneb6dcf02012-02-15 16:48:51 -0500387SQL;
Timothy Warren76e04352012-02-14 11:55:17 -0500388 }
389
390 // --------------------------------------------------------------------
391
392 /**
393 * Field data query
394 *
395 * Generates a platform-specific query so that the column data can be retrieved
396 *
Timothy Warren7221f942012-02-14 15:02:33 -0500397 * @param string the table name
398 * @return object
Timothy Warren76e04352012-02-14 11:55:17 -0500399 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500400 public function _field_data($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500401 {
Timothy Warren8be31a92012-02-15 11:48:57 -0500402 // Need to find a more efficient way to do this
403 // but Interbase/Firebird seems to lack the
404 // limit clause
405 return "SELECT * FROM {$table}";
Timothy Warren76e04352012-02-14 11:55:17 -0500406 }
407
408 // --------------------------------------------------------------------
409
410 /**
411 * The error message string
412 *
Timothy Warren7221f942012-02-14 15:02:33 -0500413 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500414 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500415 public function _error_message()
Timothy Warren76e04352012-02-14 11:55:17 -0500416 {
417 return ibase_errmsg();
418 }
419
420 // --------------------------------------------------------------------
421
422 /**
423 * The error message number
424 *
Timothy Warren7221f942012-02-14 15:02:33 -0500425 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500426 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500427 public function _error_number()
Timothy Warren76e04352012-02-14 11:55:17 -0500428 {
429 return ibase_errcode();
430 }
431
432 // --------------------------------------------------------------------
433
434 /**
435 * Escape the SQL Identifiers
436 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500437 * This public function escapes column and table names
Timothy Warren76e04352012-02-14 11:55:17 -0500438 *
Timothy Warren7221f942012-02-14 15:02:33 -0500439 * @param string
440 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500441 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500442 public function _escape_identifiers($item)
Timothy Warren76e04352012-02-14 11:55:17 -0500443 {
444 foreach ($this->_reserved_identifiers as $id)
445 {
446 if (strpos($item, '.'.$id) !== FALSE)
447 {
448 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
449
450 // remove duplicates if the user already included the escape
451 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
452 }
453 }
454
455 if (strpos($item, '.') !== FALSE)
456 {
457 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
458 }
459 else
460 {
461 $str = $this->_escape_char.$item.$this->_escape_char;
462 }
463
464 // remove duplicates if the user already included the escape
Timothy Warrend19e47a2012-02-14 23:40:40 -0500465 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
Timothy Warren76e04352012-02-14 11:55:17 -0500466 }
467
468 // --------------------------------------------------------------------
469
470 /**
471 * From Tables
472 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500473 * This public function implicitly groups FROM tables so there is no confusion
Timothy Warren76e04352012-02-14 11:55:17 -0500474 * about operator precedence in harmony with SQL standards
475 *
Timothy Warren7221f942012-02-14 15:02:33 -0500476 * @param type
477 * @return type
Timothy Warren76e04352012-02-14 11:55:17 -0500478 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500479 public function _from_tables($tables)
Timothy Warren76e04352012-02-14 11:55:17 -0500480 {
481 if ( ! is_array($tables))
482 {
483 $tables = array($tables);
484 }
485
Timothy Warren817af192012-02-16 08:28:00 -0500486 //Interbase/Firebird doesn't like grouped tables
Timothy Warrend19e47a2012-02-14 23:40:40 -0500487 return implode(', ', $tables);
Timothy Warren76e04352012-02-14 11:55:17 -0500488 }
489
490 // --------------------------------------------------------------------
491
492 /**
493 * Insert statement
494 *
495 * Generates a platform-specific insert string from the supplied data
496 *
Timothy Warren7221f942012-02-14 15:02:33 -0500497 * @param string the table name
498 * @param array the insert keys
499 * @param array the insert values
500 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500501 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500502 public function _insert($table, $keys, $values)
Timothy Warren76e04352012-02-14 11:55:17 -0500503 {
Timothy Warren817af192012-02-16 08:28:00 -0500504 return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
Timothy Warren76e04352012-02-14 11:55:17 -0500505 }
506
507 // --------------------------------------------------------------------
508
509 /**
510 * Update statement
511 *
512 * Generates a platform-specific update string from the supplied data
513 *
Timothy Warren7221f942012-02-14 15:02:33 -0500514 * @param string the table name
515 * @param array the update data
516 * @param array the where clause
517 * @param array the orderby clause
518 * @param array the limit clause
519 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500520 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500521 public function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500522 {
523 foreach ($values as $key => $val)
524 {
525 $valstr[] = $key." = ".$val;
526 }
527
Timothy Warren8be31a92012-02-15 11:48:57 -0500528 //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Timothy Warren76e04352012-02-14 11:55:17 -0500529
530 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
531
Timothy Warren817af192012-02-16 08:28:00 -0500532 $sql = "UPDATE {$table} SET ".implode(', ', $valstr);
Timothy Warren76e04352012-02-14 11:55:17 -0500533
Timothy Warren817af192012-02-16 08:28:00 -0500534 $sql .= ($where != '' AND count($where) >=1) ? ' WHERE '.implode(' ', $where) : '';
Timothy Warren76e04352012-02-14 11:55:17 -0500535
Timothy Warren8be31a92012-02-15 11:48:57 -0500536 $sql .= $orderby;
Timothy Warren76e04352012-02-14 11:55:17 -0500537
538 return $sql;
539 }
540
541
542 // --------------------------------------------------------------------
543
544 /**
545 * Truncate statement
546 *
547 * Generates a platform-specific truncate string from the supplied data
548 * If the database does not support the truncate() command
Timothy Warren4be822b2012-02-14 12:07:34 -0500549 * This public function maps to "DELETE FROM table"
Timothy Warren76e04352012-02-14 11:55:17 -0500550 *
Timothy Warren7221f942012-02-14 15:02:33 -0500551 * @param string the table name
552 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500553 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500554 public function _truncate($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500555 {
556 return $this->_delete($table);
557 }
558
559 // --------------------------------------------------------------------
560
561 /**
562 * Delete statement
563 *
564 * Generates a platform-specific delete string from the supplied data
565 *
Timothy Warren7221f942012-02-14 15:02:33 -0500566 * @param string the table name
567 * @param array the where clause
568 * @param string the limit clause
569 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500570 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500571 public function _delete($table, $where = array(), $like = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500572 {
573 $conditions = '';
574
575 if (count($where) > 0 OR count($like) > 0)
576 {
577 $conditions = "\nWHERE ";
578 $conditions .= implode("\n", $this->ar_where);
579
580 if (count($where) > 0 && count($like) > 0)
581 {
Timothy Warren817af192012-02-16 08:28:00 -0500582 $conditions .= ' AND ';
Timothy Warren76e04352012-02-14 11:55:17 -0500583 }
584 $conditions .= implode("\n", $like);
585 }
586
Timothy Warren3d985a12012-02-15 11:38:00 -0500587 //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Timothy Warren76e04352012-02-14 11:55:17 -0500588
Timothy Warren8be31a92012-02-15 11:48:57 -0500589 return "DELETE FROM {$table}{$conditions}";
Timothy Warren76e04352012-02-14 11:55:17 -0500590 }
591
592 // --------------------------------------------------------------------
593
594 /**
595 * Limit string
596 *
597 * Generates a platform-specific LIMIT clause
598 *
Timothy Warren7221f942012-02-14 15:02:33 -0500599 * @param string the sql query string
600 * @param integer the number of rows to limit the query to
601 * @param integer the offset value
602 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500603 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500604 public function _limit($sql, $limit, $offset)
Timothy Warren76e04352012-02-14 11:55:17 -0500605 {
Timothy Warren3d985a12012-02-15 11:38:00 -0500606 //There doesn't seem to be a limit clause?
607 return $sql;
Timothy Warren76e04352012-02-14 11:55:17 -0500608 }
609
610 // --------------------------------------------------------------------
611
612 /**
613 * Close DB Connection
614 *
Timothy Warren7221f942012-02-14 15:02:33 -0500615 * @param resource
616 * @return void
Timothy Warren76e04352012-02-14 11:55:17 -0500617 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500618 public function _close($conn_id)
Timothy Warren76e04352012-02-14 11:55:17 -0500619 {
Timothy Warren7221f942012-02-14 15:02:33 -0500620 @ibase_close($conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500621 }
Timothy Warren76e04352012-02-14 11:55:17 -0500622}
623
Timothy Warren76e04352012-02-14 11:55:17 -0500624/* End of file interbase_driver.php */
625/* Location: ./system/database/drivers/interbase/interbase_driver.php */