blob: 197c01401e6054c56476f2530621796c3bb660b3 [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 Warren3d985a12012-02-15 11:38:00 -0500155 // Must be determined at connection
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 Warren3d985a12012-02-15 11:38:00 -0500169 if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
170 {
171 $version = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
172 return $version;
173 }
174
175 return FALSE;
Timothy Warren76e04352012-02-14 11:55:17 -0500176 }
177
178 // --------------------------------------------------------------------
179
180 /**
181 * Execute the query
182 *
Timothy Warren7221f942012-02-14 15:02:33 -0500183 * @access private called by the base class
184 * @param string an SQL query
185 * @return resource
Timothy Warren76e04352012-02-14 11:55:17 -0500186 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500187 public function _execute($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500188 {
189 $sql = $this->_prep_query($sql);
Timothy Warren7221f942012-02-14 15:02:33 -0500190 return @ibase_query($this->conn_id, $sql);
Timothy Warren76e04352012-02-14 11:55:17 -0500191 }
192
193 // --------------------------------------------------------------------
194
195 /**
196 * Prep the query
197 *
198 * If needed, each database adapter can prep the query string
199 *
Timothy Warren7221f942012-02-14 15:02:33 -0500200 * @access private called by execute()
201 * @param string an SQL query
202 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500203 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500204 public function _prep_query($sql)
Timothy Warren76e04352012-02-14 11:55:17 -0500205 {
206 return $sql;
207 }
208
209 // --------------------------------------------------------------------
210
211 /**
212 * Begin Transaction
213 *
Timothy Warren7221f942012-02-14 15:02:33 -0500214 * @access public
215 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500216 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500217 public function trans_begin($test_mode = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500218 {
219 if ( ! $this->trans_enabled)
220 {
221 return TRUE;
222 }
223
224 // When transactions are nested we only begin/commit/rollback the outermost ones
225 if ($this->_trans_depth > 0)
226 {
227 return TRUE;
228 }
229
230 // Reset the transaction failure flag.
231 // If the $test_mode flag is set to TRUE transactions will be rolled back
232 // even if the queries produce a successful result.
233 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
234
Timothy Warren7221f942012-02-14 15:02:33 -0500235 $this->trans = @ibase_trans($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500236
237 return TRUE;
238 }
239
240 // --------------------------------------------------------------------
241
242 /**
243 * Commit Transaction
244 *
Timothy Warren7221f942012-02-14 15:02:33 -0500245 * @access public
246 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500247 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500248 public function trans_commit()
Timothy Warren76e04352012-02-14 11:55:17 -0500249 {
250 if ( ! $this->trans_enabled)
251 {
252 return TRUE;
253 }
254
255 // When transactions are nested we only begin/commit/rollback the outermost ones
256 if ($this->_trans_depth > 0)
257 {
258 return TRUE;
259 }
260
Timothy Warren7221f942012-02-14 15:02:33 -0500261 @ibase_commit($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500262
263 return TRUE;
264 }
265
266 // --------------------------------------------------------------------
267
268 /**
269 * Rollback Transaction
270 *
Timothy Warren7221f942012-02-14 15:02:33 -0500271 * @access public
272 * @return bool
Timothy Warren76e04352012-02-14 11:55:17 -0500273 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500274 public function trans_rollback()
Timothy Warren76e04352012-02-14 11:55:17 -0500275 {
276 if ( ! $this->trans_enabled)
277 {
278 return TRUE;
279 }
280
281 // When transactions are nested we only begin/commit/rollback the outermost ones
282 if ($this->_trans_depth > 0)
283 {
284 return TRUE;
285 }
286
Timothy Warren7221f942012-02-14 15:02:33 -0500287 @ibase_rollback($this->trans);
Timothy Warren76e04352012-02-14 11:55:17 -0500288
289 return TRUE;
290 }
291
292 // --------------------------------------------------------------------
293
294 /**
295 * Escape String
296 *
Timothy Warren7221f942012-02-14 15:02:33 -0500297 * @access public
298 * @param string
299 * @param bool whether or not the string will be used in a LIKE condition
300 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500301 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500302 public function escape_str($str, $like = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500303 {
304 if (is_array($str))
305 {
306 foreach ($str as $key => $val)
307 {
308 $str[$key] = $this->escape_str($val, $like);
309 }
310
311 return $str;
312 }
313
314 // escape LIKE condition wildcards
315 if ($like === TRUE)
316 {
317 $str = str_replace( array('%', '_', $this->_like_escape_chr),
318 array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
319 $str);
320 }
321
322 return $str;
323 }
324
325 // --------------------------------------------------------------------
326
327 /**
328 * Affected Rows
329 *
Timothy Warren7221f942012-02-14 15:02:33 -0500330 * @access public
331 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500332 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500333 public function affected_rows()
Timothy Warren76e04352012-02-14 11:55:17 -0500334 {
Timothy Warren7221f942012-02-14 15:02:33 -0500335 return @ibase_affected_rows($this->conn_id);
Timothy Warren76e04352012-02-14 11:55:17 -0500336 }
337
338 // --------------------------------------------------------------------
339
340 /**
341 * Insert ID
342 *
Timothy Warren7221f942012-02-14 15:02:33 -0500343 * @access public
344 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500345 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500346 public function insert_id()
Timothy Warren76e04352012-02-14 11:55:17 -0500347 {
Timothy Warren7221f942012-02-14 15:02:33 -0500348 //@todo Implement manually
Timothy Warren76e04352012-02-14 11:55:17 -0500349 return 0;
350 }
351
352 // --------------------------------------------------------------------
353
354 /**
355 * "Count All" query
356 *
357 * Generates a platform-specific query string that counts all records in
358 * the specified database
359 *
Timothy Warren7221f942012-02-14 15:02:33 -0500360 * @access public
361 * @param string
362 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500363 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500364 public function count_all($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500365 {
366 if ($table == '')
367 {
368 return 0;
369 }
370
371 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
372
373 if ($query->num_rows() == 0)
374 {
375 return 0;
376 }
377
378 $row = $query->row();
379 $this->_reset_select();
380 return (int) $row->numrows;
381 }
382
383 // --------------------------------------------------------------------
384
385 /**
386 * List table query
387 *
388 * Generates a platform-specific query string so that the table names can be fetched
389 *
Timothy Warren7221f942012-02-14 15:02:33 -0500390 * @access private
391 * @param boolean
392 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500393 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500394 public function _list_tables($prefix_limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500395 {
396 $sql = <<<SQL
397 SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
398 WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
399 AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
400SQL;
401
402 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
403 {
Timothy Warren3d985a12012-02-15 11:38:00 -0500404 $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 -0500405 }
406 return $sql;
407 }
408
409 // --------------------------------------------------------------------
410
411 /**
412 * Show column query
413 *
414 * Generates a platform-specific query string so that the column names can be fetched
415 *
Timothy Warren7221f942012-02-14 15:02:33 -0500416 * @access public
417 * @param string the table name
418 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500419 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500420 public function _list_columns($table = '')
Timothy Warren76e04352012-02-14 11:55:17 -0500421 {
422 // Not supported
423 return FALSE;
424 }
425
426 // --------------------------------------------------------------------
427
428 /**
429 * Field data query
430 *
431 * Generates a platform-specific query so that the column data can be retrieved
432 *
Timothy Warren7221f942012-02-14 15:02:33 -0500433 * @access public
434 * @param string the table name
435 * @return object
Timothy Warren76e04352012-02-14 11:55:17 -0500436 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500437 public function _field_data($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500438 {
Timothy Warren8be31a92012-02-15 11:48:57 -0500439 // Need to find a more efficient way to do this
440 // but Interbase/Firebird seems to lack the
441 // limit clause
442 return "SELECT * FROM {$table}";
Timothy Warren76e04352012-02-14 11:55:17 -0500443 }
444
445 // --------------------------------------------------------------------
446
447 /**
448 * The error message string
449 *
Timothy Warren7221f942012-02-14 15:02:33 -0500450 * @access private
451 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500452 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500453 public function _error_message()
Timothy Warren76e04352012-02-14 11:55:17 -0500454 {
455 return ibase_errmsg();
456 }
457
458 // --------------------------------------------------------------------
459
460 /**
461 * The error message number
462 *
Timothy Warren7221f942012-02-14 15:02:33 -0500463 * @access private
464 * @return integer
Timothy Warren76e04352012-02-14 11:55:17 -0500465 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500466 public function _error_number()
Timothy Warren76e04352012-02-14 11:55:17 -0500467 {
468 return ibase_errcode();
469 }
470
471 // --------------------------------------------------------------------
472
473 /**
474 * Escape the SQL Identifiers
475 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500476 * This public function escapes column and table names
Timothy Warren76e04352012-02-14 11:55:17 -0500477 *
Timothy Warren7221f942012-02-14 15:02:33 -0500478 * @access private
479 * @param string
480 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500481 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500482 public function _escape_identifiers($item)
Timothy Warren76e04352012-02-14 11:55:17 -0500483 {
484 foreach ($this->_reserved_identifiers as $id)
485 {
486 if (strpos($item, '.'.$id) !== FALSE)
487 {
488 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
489
490 // remove duplicates if the user already included the escape
491 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
492 }
493 }
494
495 if (strpos($item, '.') !== FALSE)
496 {
497 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
498 }
499 else
500 {
501 $str = $this->_escape_char.$item.$this->_escape_char;
502 }
503
504 // remove duplicates if the user already included the escape
Timothy Warrend19e47a2012-02-14 23:40:40 -0500505 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
Timothy Warren76e04352012-02-14 11:55:17 -0500506 }
507
508 // --------------------------------------------------------------------
509
510 /**
511 * From Tables
512 *
Timothy Warren4be822b2012-02-14 12:07:34 -0500513 * This public function implicitly groups FROM tables so there is no confusion
Timothy Warren76e04352012-02-14 11:55:17 -0500514 * about operator precedence in harmony with SQL standards
515 *
Timothy Warren7221f942012-02-14 15:02:33 -0500516 * @access public
517 * @param type
518 * @return type
Timothy Warren76e04352012-02-14 11:55:17 -0500519 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500520 public function _from_tables($tables)
Timothy Warren76e04352012-02-14 11:55:17 -0500521 {
522 if ( ! is_array($tables))
523 {
524 $tables = array($tables);
525 }
526
Timothy Warrend19e47a2012-02-14 23:40:40 -0500527 return implode(', ', $tables);
Timothy Warren76e04352012-02-14 11:55:17 -0500528 }
529
530 // --------------------------------------------------------------------
531
532 /**
533 * Insert statement
534 *
535 * Generates a platform-specific insert string from the supplied data
536 *
Timothy Warren7221f942012-02-14 15:02:33 -0500537 * @access public
538 * @param string the table name
539 * @param array the insert keys
540 * @param array the insert values
541 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500542 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500543 public function _insert($table, $keys, $values)
Timothy Warren76e04352012-02-14 11:55:17 -0500544 {
Timothy Warrend19e47a2012-02-14 23:40:40 -0500545 return "INSERT INTO {$table} (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
Timothy Warren76e04352012-02-14 11:55:17 -0500546 }
547
548 // --------------------------------------------------------------------
549
550 /**
551 * Update statement
552 *
553 * Generates a platform-specific update string from the supplied data
554 *
Timothy Warren7221f942012-02-14 15:02:33 -0500555 * @access public
556 * @param string the table name
557 * @param array the update data
558 * @param array the where clause
559 * @param array the orderby clause
560 * @param array the limit clause
561 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500562 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500563 public function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500564 {
565 foreach ($values as $key => $val)
566 {
567 $valstr[] = $key." = ".$val;
568 }
569
Timothy Warren8be31a92012-02-15 11:48:57 -0500570 //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Timothy Warren76e04352012-02-14 11:55:17 -0500571
572 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
573
574 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
575
576 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
577
Timothy Warren8be31a92012-02-15 11:48:57 -0500578 $sql .= $orderby;
Timothy Warren76e04352012-02-14 11:55:17 -0500579
580 return $sql;
581 }
582
583
584 // --------------------------------------------------------------------
585
586 /**
587 * Truncate statement
588 *
589 * Generates a platform-specific truncate string from the supplied data
590 * If the database does not support the truncate() command
Timothy Warren4be822b2012-02-14 12:07:34 -0500591 * This public function maps to "DELETE FROM table"
Timothy Warren76e04352012-02-14 11:55:17 -0500592 *
Timothy Warren7221f942012-02-14 15:02:33 -0500593 * @access public
594 * @param string the table name
595 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500596 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500597 public function _truncate($table)
Timothy Warren76e04352012-02-14 11:55:17 -0500598 {
599 return $this->_delete($table);
600 }
601
602 // --------------------------------------------------------------------
603
604 /**
605 * Delete statement
606 *
607 * Generates a platform-specific delete string from the supplied data
608 *
Timothy Warren7221f942012-02-14 15:02:33 -0500609 * @access public
610 * @param string the table name
611 * @param array the where clause
612 * @param string the limit clause
613 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500614 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500615 public function _delete($table, $where = array(), $like = array(), $limit = FALSE)
Timothy Warren76e04352012-02-14 11:55:17 -0500616 {
617 $conditions = '';
618
619 if (count($where) > 0 OR count($like) > 0)
620 {
621 $conditions = "\nWHERE ";
622 $conditions .= implode("\n", $this->ar_where);
623
624 if (count($where) > 0 && count($like) > 0)
625 {
626 $conditions .= " AND ";
627 }
628 $conditions .= implode("\n", $like);
629 }
630
Timothy Warren3d985a12012-02-15 11:38:00 -0500631 //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Timothy Warren76e04352012-02-14 11:55:17 -0500632
Timothy Warren8be31a92012-02-15 11:48:57 -0500633 return "DELETE FROM {$table}{$conditions}";
Timothy Warren76e04352012-02-14 11:55:17 -0500634 }
635
636 // --------------------------------------------------------------------
637
638 /**
639 * Limit string
640 *
641 * Generates a platform-specific LIMIT clause
642 *
Timothy Warren7221f942012-02-14 15:02:33 -0500643 * @access public
644 * @param string the sql query string
645 * @param integer the number of rows to limit the query to
646 * @param integer the offset value
647 * @return string
Timothy Warren76e04352012-02-14 11:55:17 -0500648 */
Timothy Warren4be822b2012-02-14 12:07:34 -0500649 public function _limit($sql, $limit, $offset)
Timothy Warren76e04352012-02-14 11:55:17 -0500650 {
Timothy Warren3d985a12012-02-15 11:38:00 -0500651 //There doesn't seem to be a limit clause?
652 return $sql;
Timothy Warren76e04352012-02-14 11:55:17 -0500653 }
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
Timothy Warren76e04352012-02-14 11:55:17 -0500670/* End of file interbase_driver.php */
671/* Location: ./system/database/drivers/interbase/interbase_driver.php */