blob: 89541e5fa3012ec9d1f56c35207404fd13984e9c [file] [log] [blame]
Derek Jones4b9c6292011-07-01 17:40:48 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * 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
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Derek Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
Greg Aker0defe5d2012-01-01 18:46:41 -060021 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * Postgre 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 *
37 * @package CodeIgniter
38 * @subpackage Drivers
39 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050040 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000041 * @link http://codeigniter.com/user_guide/database/
42 */
43class CI_DB_postgre_driver extends CI_DB {
44
45 var $dbdriver = 'postgre';
Barry Mienydd671972010-10-04 16:33:58 +020046
Derek Allard2067d1a2008-11-13 22:59:24 +000047 var $_escape_char = '"';
48
Derek Jonese4ed5832009-02-20 21:44:59 +000049 // clause and character used for LIKE escape sequences
50 var $_like_escape_str = " ESCAPE '%s' ";
51 var $_like_escape_chr = '!';
52
Derek Allard2067d1a2008-11-13 22:59:24 +000053 /**
54 * The syntax to count rows is slightly different across different
55 * database engines, so this string appears in each driver and is
56 * used for the count_all() and count_all_results() functions.
57 */
58 var $_count_string = "SELECT COUNT(*) AS ";
59 var $_random_keyword = ' RANDOM()'; // database specific random keyword
60
61 /**
62 * Connection String
63 *
64 * @access private
65 * @return string
Barry Mienydd671972010-10-04 16:33:58 +020066 */
Derek Allard2067d1a2008-11-13 22:59:24 +000067 function _connect_string()
68 {
69 $components = array(
70 'hostname' => 'host',
71 'port' => 'port',
72 'database' => 'dbname',
73 'username' => 'user',
74 'password' => 'password'
75 );
Barry Mienydd671972010-10-04 16:33:58 +020076
Derek Allard2067d1a2008-11-13 22:59:24 +000077 $connect_string = "";
78 foreach ($components as $key => $val)
79 {
80 if (isset($this->$key) && $this->$key != '')
81 {
82 $connect_string .= " $val=".$this->$key;
83 }
84 }
85 return trim($connect_string);
86 }
87
88 // --------------------------------------------------------------------
89
90 /**
91 * Non-persistent database connection
92 *
93 * @access private called by the base class
94 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +020095 */
Derek Allard2067d1a2008-11-13 22:59:24 +000096 function db_connect()
Barry Mienydd671972010-10-04 16:33:58 +020097 {
Derek Allard2067d1a2008-11-13 22:59:24 +000098 return @pg_connect($this->_connect_string());
99 }
100
101 // --------------------------------------------------------------------
102
103 /**
104 * Persistent database connection
105 *
106 * @access private called by the base class
107 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +0200108 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000109 function db_pconnect()
110 {
111 return @pg_pconnect($this->_connect_string());
112 }
Barry Mienydd671972010-10-04 16:33:58 +0200113
Derek Allard2067d1a2008-11-13 22:59:24 +0000114 // --------------------------------------------------------------------
115
116 /**
Derek Jones87cbafc2009-02-27 16:29:59 +0000117 * Reconnect
118 *
119 * Keep / reestablish the db connection if no queries have been
120 * sent for a length of time exceeding the server's idle timeout
121 *
122 * @access public
123 * @return void
124 */
125 function reconnect()
126 {
127 if (pg_ping($this->conn_id) === FALSE)
128 {
129 $this->conn_id = FALSE;
130 }
131 }
132
133 // --------------------------------------------------------------------
134
135 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000136 * Select the database
137 *
138 * @access private called by the base class
139 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +0200140 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000141 function db_select()
142 {
143 // Not needed for Postgre so we'll return TRUE
144 return TRUE;
145 }
146
147 // --------------------------------------------------------------------
148
149 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000150 * Version number query string
151 *
152 * @access public
153 * @return string
154 */
155 function _version()
156 {
157 return "SELECT version() AS ver";
158 }
159
160 // --------------------------------------------------------------------
161
162 /**
163 * Execute the query
164 *
165 * @access private called by the base class
166 * @param string an SQL query
167 * @return resource
Barry Mienydd671972010-10-04 16:33:58 +0200168 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000169 function _execute($sql)
170 {
171 $sql = $this->_prep_query($sql);
172 return @pg_query($this->conn_id, $sql);
173 }
Barry Mienydd671972010-10-04 16:33:58 +0200174
Derek Allard2067d1a2008-11-13 22:59:24 +0000175 // --------------------------------------------------------------------
176
177 /**
178 * Prep the query
179 *
180 * If needed, each database adapter can prep the query string
181 *
182 * @access private called by execute()
183 * @param string an SQL query
184 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200185 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000186 function _prep_query($sql)
187 {
188 return $sql;
189 }
190
191 // --------------------------------------------------------------------
192
193 /**
194 * Begin Transaction
195 *
196 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200197 * @return bool
198 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000199 function trans_begin($test_mode = FALSE)
200 {
201 if ( ! $this->trans_enabled)
202 {
203 return TRUE;
204 }
Barry Mienydd671972010-10-04 16:33:58 +0200205
Derek Allard2067d1a2008-11-13 22:59:24 +0000206 // When transactions are nested we only begin/commit/rollback the outermost ones
207 if ($this->_trans_depth > 0)
208 {
209 return TRUE;
210 }
211
212 // Reset the transaction failure flag.
213 // If the $test_mode flag is set to TRUE transactions will be rolled back
214 // even if the queries produce a successful result.
215 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
216
217 return @pg_exec($this->conn_id, "begin");
218 }
219
220 // --------------------------------------------------------------------
221
222 /**
223 * Commit Transaction
224 *
225 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200226 * @return bool
227 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000228 function trans_commit()
229 {
230 if ( ! $this->trans_enabled)
231 {
232 return TRUE;
233 }
234
235 // When transactions are nested we only begin/commit/rollback the outermost ones
236 if ($this->_trans_depth > 0)
237 {
238 return TRUE;
239 }
240
241 return @pg_exec($this->conn_id, "commit");
242 }
243
244 // --------------------------------------------------------------------
245
246 /**
247 * Rollback Transaction
248 *
249 * @access public
Barry Mienydd671972010-10-04 16:33:58 +0200250 * @return bool
251 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000252 function trans_rollback()
253 {
254 if ( ! $this->trans_enabled)
255 {
256 return TRUE;
257 }
258
259 // When transactions are nested we only begin/commit/rollback the outermost ones
260 if ($this->_trans_depth > 0)
261 {
262 return TRUE;
263 }
264
265 return @pg_exec($this->conn_id, "rollback");
266 }
267
268 // --------------------------------------------------------------------
269
270 /**
271 * Escape String
272 *
273 * @access public
274 * @param string
Derek Jonese4ed5832009-02-20 21:44:59 +0000275 * @param bool whether or not the string will be used in a LIKE condition
Derek Allard2067d1a2008-11-13 22:59:24 +0000276 * @return string
277 */
Derek Jonese4ed5832009-02-20 21:44:59 +0000278 function escape_str($str, $like = FALSE)
279 {
280 if (is_array($str))
281 {
Pascal Krietec3a4a8d2011-02-14 13:40:08 -0500282 foreach ($str as $key => $val)
Barry Mienydd671972010-10-04 16:33:58 +0200283 {
Derek Jonese4ed5832009-02-20 21:44:59 +0000284 $str[$key] = $this->escape_str($val, $like);
Barry Mienydd671972010-10-04 16:33:58 +0200285 }
286
287 return $str;
288 }
Derek Jonese4ed5832009-02-20 21:44:59 +0000289
290 $str = pg_escape_string($str);
Barry Mienydd671972010-10-04 16:33:58 +0200291
Derek Jonese4ed5832009-02-20 21:44:59 +0000292 // escape LIKE condition wildcards
293 if ($like === TRUE)
294 {
295 $str = str_replace( array('%', '_', $this->_like_escape_chr),
296 array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
297 $str);
298 }
Barry Mienydd671972010-10-04 16:33:58 +0200299
Derek Jonese4ed5832009-02-20 21:44:59 +0000300 return $str;
Derek Allard2067d1a2008-11-13 22:59:24 +0000301 }
Barry Mienydd671972010-10-04 16:33:58 +0200302
Derek Allard2067d1a2008-11-13 22:59:24 +0000303 // --------------------------------------------------------------------
304
305 /**
306 * Affected Rows
307 *
308 * @access public
309 * @return integer
310 */
311 function affected_rows()
312 {
313 return @pg_affected_rows($this->result_id);
314 }
Barry Mienydd671972010-10-04 16:33:58 +0200315
Derek Allard2067d1a2008-11-13 22:59:24 +0000316 // --------------------------------------------------------------------
317
318 /**
319 * Insert ID
320 *
321 * @access public
322 * @return integer
323 */
324 function insert_id()
325 {
326 $v = $this->_version();
327 $v = $v['server'];
Barry Mienydd671972010-10-04 16:33:58 +0200328
Pascal Kriete8761ef52011-02-14 13:13:52 -0500329 $table = func_num_args() > 0 ? func_get_arg(0) : NULL;
330 $column = func_num_args() > 1 ? func_get_arg(1) : NULL;
Barry Mienydd671972010-10-04 16:33:58 +0200331
Pascal Kriete8761ef52011-02-14 13:13:52 -0500332 if ($table == NULL && $v >= '8.1')
Derek Allard2067d1a2008-11-13 22:59:24 +0000333 {
334 $sql='SELECT LASTVAL() as ins_id';
335 }
Pascal Kriete8761ef52011-02-14 13:13:52 -0500336 elseif ($table != NULL && $column != NULL && $v >= '8.0')
Derek Allard2067d1a2008-11-13 22:59:24 +0000337 {
338 $sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
339 $query = $this->query($sql);
340 $row = $query->row();
341 $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);
342 }
Pascal Kriete8761ef52011-02-14 13:13:52 -0500343 elseif ($table != NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000344 {
345 // seq_name passed in table parameter
346 $sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
347 }
348 else
349 {
350 return pg_last_oid($this->result_id);
351 }
352 $query = $this->query($sql);
353 $row = $query->row();
354 return $row->ins_id;
355 }
356
357 // --------------------------------------------------------------------
358
359 /**
360 * "Count All" query
361 *
362 * Generates a platform-specific query string that counts all records in
363 * the specified database
364 *
365 * @access public
366 * @param string
367 * @return string
368 */
369 function count_all($table = '')
370 {
371 if ($table == '')
Derek Allarde37ab382009-02-03 16:13:57 +0000372 {
373 return 0;
374 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000375
Derek Allarde37ab382009-02-03 16:13:57 +0000376 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
377
Derek Allard2067d1a2008-11-13 22:59:24 +0000378 if ($query->num_rows() == 0)
Derek Allarde37ab382009-02-03 16:13:57 +0000379 {
380 return 0;
381 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000382
383 $row = $query->row();
Greg Aker90248ab2011-08-20 14:23:14 -0500384 $this->_reset_select();
Derek Allarde37ab382009-02-03 16:13:57 +0000385 return (int) $row->numrows;
Derek Allard2067d1a2008-11-13 22:59:24 +0000386 }
387
388 // --------------------------------------------------------------------
389
390 /**
391 * Show table query
392 *
393 * Generates a platform-specific query string so that the table names can be fetched
394 *
395 * @access private
396 * @param boolean
397 * @return string
398 */
399 function _list_tables($prefix_limit = FALSE)
Barry Mienydd671972010-10-04 16:33:58 +0200400 {
401 $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
402
Derek Allard2067d1a2008-11-13 22:59:24 +0000403 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
404 {
Greg Aker0d424892010-01-26 02:14:44 +0000405 $sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
Derek Allard2067d1a2008-11-13 22:59:24 +0000406 }
Barry Mienydd671972010-10-04 16:33:58 +0200407
Derek Allard2067d1a2008-11-13 22:59:24 +0000408 return $sql;
409 }
Barry Mienydd671972010-10-04 16:33:58 +0200410
Derek Allard2067d1a2008-11-13 22:59:24 +0000411 // --------------------------------------------------------------------
412
413 /**
414 * Show column query
415 *
416 * Generates a platform-specific query string so that the column names can be fetched
417 *
418 * @access public
419 * @param string the table name
420 * @return string
421 */
422 function _list_columns($table = '')
423 {
424 return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
425 }
426
427 // --------------------------------------------------------------------
428
429 /**
430 * Field data query
431 *
432 * Generates a platform-specific query so that the column data can be retrieved
433 *
434 * @access public
435 * @param string the table name
436 * @return object
437 */
438 function _field_data($table)
439 {
440 return "SELECT * FROM ".$table." LIMIT 1";
441 }
442
443 // --------------------------------------------------------------------
444
445 /**
446 * The error message string
447 *
448 * @access private
449 * @return string
450 */
451 function _error_message()
452 {
453 return pg_last_error($this->conn_id);
454 }
Barry Mienydd671972010-10-04 16:33:58 +0200455
Derek Allard2067d1a2008-11-13 22:59:24 +0000456 // --------------------------------------------------------------------
457
458 /**
459 * The error message number
460 *
461 * @access private
462 * @return integer
463 */
464 function _error_number()
465 {
466 return '';
467 }
468
469 // --------------------------------------------------------------------
470
471 /**
472 * Escape the SQL Identifiers
473 *
474 * This function escapes column and table names
475 *
476 * @access private
477 * @param string
478 * @return string
479 */
480 function _escape_identifiers($item)
481 {
482 if ($this->_escape_char == '')
483 {
484 return $item;
485 }
486
487 foreach ($this->_reserved_identifiers as $id)
488 {
489 if (strpos($item, '.'.$id) !== FALSE)
490 {
Barry Mienydd671972010-10-04 16:33:58 +0200491 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
492
Derek Allard2067d1a2008-11-13 22:59:24 +0000493 // remove duplicates if the user already included the escape
494 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
Barry Mienydd671972010-10-04 16:33:58 +0200495 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000496 }
Barry Mienydd671972010-10-04 16:33:58 +0200497
Derek Allard2067d1a2008-11-13 22:59:24 +0000498 if (strpos($item, '.') !== FALSE)
499 {
Barry Mienydd671972010-10-04 16:33:58 +0200500 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
Derek Allard2067d1a2008-11-13 22:59:24 +0000501 }
502 else
503 {
504 $str = $this->_escape_char.$item.$this->_escape_char;
505 }
Barry Mienydd671972010-10-04 16:33:58 +0200506
Derek Allard2067d1a2008-11-13 22:59:24 +0000507 // remove duplicates if the user already included the escape
508 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
509 }
Barry Mienydd671972010-10-04 16:33:58 +0200510
Derek Allard2067d1a2008-11-13 22:59:24 +0000511 // --------------------------------------------------------------------
512
513 /**
514 * From Tables
515 *
516 * This function implicitly groups FROM tables so there is no confusion
517 * about operator precedence in harmony with SQL standards
518 *
519 * @access public
520 * @param type
521 * @return type
522 */
523 function _from_tables($tables)
524 {
525 if ( ! is_array($tables))
526 {
527 $tables = array($tables);
528 }
Barry Mienydd671972010-10-04 16:33:58 +0200529
Derek Allard2067d1a2008-11-13 22:59:24 +0000530 return implode(', ', $tables);
531 }
532
533 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200534
Derek Allard2067d1a2008-11-13 22:59:24 +0000535 /**
536 * Insert statement
537 *
538 * Generates a platform-specific insert string from the supplied data
539 *
540 * @access public
541 * @param string the table name
542 * @param array the insert keys
543 * @param array the insert values
544 * @return string
545 */
546 function _insert($table, $keys, $values)
Barry Mienydd671972010-10-04 16:33:58 +0200547 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000548 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
549 }
Barry Mienydd671972010-10-04 16:33:58 +0200550
Derek Allard2067d1a2008-11-13 22:59:24 +0000551 // --------------------------------------------------------------------
552
553 /**
Greg Aker60ef4ea2011-04-27 01:45:38 -0500554 * Insert_batch statement
555 *
556 * Generates a platform-specific insert string from the supplied data
557 *
558 * @access public
559 * @param string the table name
560 * @param array the insert keys
561 * @param array the insert values
562 * @return string
563 */
564 function _insert_batch($table, $keys, $values)
565 {
566 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
567 }
568
569 // --------------------------------------------------------------------
570
571 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000572 * Update statement
573 *
574 * Generates a platform-specific update string from the supplied data
575 *
576 * @access public
577 * @param string the table name
578 * @param array the update data
579 * @param array the where clause
580 * @param array the orderby clause
581 * @param array the limit clause
582 * @return string
583 */
584 function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
585 {
Pascal Krietec3a4a8d2011-02-14 13:40:08 -0500586 foreach ($values as $key => $val)
Derek Allard2067d1a2008-11-13 22:59:24 +0000587 {
588 $valstr[] = $key." = ".$val;
589 }
Barry Mienydd671972010-10-04 16:33:58 +0200590
Derek Allard2067d1a2008-11-13 22:59:24 +0000591 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200592
Derek Allard2067d1a2008-11-13 22:59:24 +0000593 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
Barry Mienydd671972010-10-04 16:33:58 +0200594
Derek Allard2067d1a2008-11-13 22:59:24 +0000595 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
596
597 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
598
599 $sql .= $orderby.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200600
Derek Allard2067d1a2008-11-13 22:59:24 +0000601 return $sql;
602 }
603
604 // --------------------------------------------------------------------
605
606 /**
607 * Truncate statement
608 *
609 * Generates a platform-specific truncate string from the supplied data
610 * If the database does not support the truncate() command
611 * This function maps to "DELETE FROM table"
612 *
613 * @access public
614 * @param string the table name
615 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200616 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000617 function _truncate($table)
618 {
619 return "TRUNCATE ".$table;
620 }
Barry Mienydd671972010-10-04 16:33:58 +0200621
Derek Allard2067d1a2008-11-13 22:59:24 +0000622 // --------------------------------------------------------------------
623
624 /**
625 * Delete statement
626 *
627 * Generates a platform-specific delete string from the supplied data
628 *
629 * @access public
630 * @param string the table name
631 * @param array the where clause
632 * @param string the limit clause
633 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200634 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000635 function _delete($table, $where = array(), $like = array(), $limit = FALSE)
636 {
637 $conditions = '';
638
639 if (count($where) > 0 OR count($like) > 0)
640 {
641 $conditions = "\nWHERE ";
642 $conditions .= implode("\n", $this->ar_where);
643
644 if (count($where) > 0 && count($like) > 0)
645 {
646 $conditions .= " AND ";
647 }
648 $conditions .= implode("\n", $like);
649 }
650
651 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200652
Derek Allard2067d1a2008-11-13 22:59:24 +0000653 return "DELETE FROM ".$table.$conditions.$limit;
654 }
655
656 // --------------------------------------------------------------------
657 /**
658 * Limit string
659 *
660 * Generates a platform-specific LIMIT clause
661 *
662 * @access public
663 * @param string the sql query string
664 * @param integer the number of rows to limit the query to
665 * @param integer the offset value
666 * @return string
667 */
668 function _limit($sql, $limit, $offset)
Barry Mienydd671972010-10-04 16:33:58 +0200669 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000670 $sql .= "LIMIT ".$limit;
Barry Mienydd671972010-10-04 16:33:58 +0200671
Derek Allard2067d1a2008-11-13 22:59:24 +0000672 if ($offset > 0)
673 {
674 $sql .= " OFFSET ".$offset;
675 }
Barry Mienydd671972010-10-04 16:33:58 +0200676
Derek Allard2067d1a2008-11-13 22:59:24 +0000677 return $sql;
678 }
679
680 // --------------------------------------------------------------------
681
682 /**
683 * Close DB Connection
684 *
685 * @access public
686 * @param resource
687 * @return void
688 */
689 function _close($conn_id)
690 {
691 @pg_close($conn_id);
692 }
693
694
695}
696
697
698/* End of file postgre_driver.php */
Andrey Andreev063f5962012-02-27 12:20:52 +0200699/* Location: ./system/database/drivers/postgre/postgre_driver.php */