blob: 944df99b51eb60c1818e80f24ab61a399ca0a406 [file] [log] [blame]
Andrey Andreev592f4ec2012-03-20 15:10:08 +02001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Esen Sagynov2e087942011-08-09 23:35:01 -07002/**
3 * CodeIgniter
4 *
Phil Sturgeon07c1ac82012-03-09 17:03:37 +00005 * An open source application development framework for PHP 5.2.4 or newer
Esen Sagynov2e087942011-08-09 23:35:01 -07006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreev592f4ec2012-03-20 15:10:08 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreev592f4ec2012-03-20 15:10:08 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -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
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Esen Sagynov2e087942011-08-09 23:35:01 -070019 * @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)
Esen Sagynov2e087942011-08-09 23:35:01 -070023 * @link http://codeigniter.com
Andrey Andreevcf631202012-02-16 11:36:28 +020024 * @since Version 2.1
Esen Sagynov2e087942011-08-09 23:35:01 -070025 * @filesource
26 */
27
Esen Sagynov2e087942011-08-09 23:35:01 -070028/**
29 * CUBRID Database Adapter Class
30 *
31 * Note: _DB is an extender class that the app controller
Jamie Rumbelow7efad202012-02-19 12:37:00 +000032 * creates dynamically based on whether the query builder
Esen Sagynov2e087942011-08-09 23:35:01 -070033 * class is being used or not.
34 *
35 * @package CodeIgniter
36 * @subpackage Drivers
37 * @category Database
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -070038 * @author Esen Sagynov
Esen Sagynov2e087942011-08-09 23:35:01 -070039 * @link http://codeigniter.com/user_guide/database/
40 */
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -070041class CI_DB_cubrid_driver extends CI_DB {
42
Andrey Andreev592f4ec2012-03-20 15:10:08 +020043 public $dbdriver = 'cubrid';
Esen Sagynov2e087942011-08-09 23:35:01 -070044
45 // The character used for escaping - no need in CUBRID
Andrey Andreev394a3f12012-02-15 14:35:11 +020046 protected $_escape_char = '`';
Esen Sagynov2e087942011-08-09 23:35:01 -070047
48 // clause and character used for LIKE escape sequences - not used in CUBRID
Andrey Andreev592f4ec2012-03-20 15:10:08 +020049 protected $_like_escape_str = '';
50 protected $_like_escape_chr = '';
Esen Sagynov2e087942011-08-09 23:35:01 -070051
52 /**
53 * The syntax to count rows is slightly different across different
54 * database engines, so this string appears in each driver and is
55 * used for the count_all() and count_all_results() functions.
56 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +020057 protected $_count_string = 'SELECT COUNT(*) AS ';
58 protected $_random_keyword = ' RAND()'; // database specific random keyword
Esen Sagynov2e087942011-08-09 23:35:01 -070059
Andrey Andreeva00e5042012-03-26 12:23:13 +030060 // CUBRID-specific properties
61 public $auto_commit = TRUE;
62
63 public function __construct($params)
64 {
65 parent::__construct($params);
66
67 if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches))
68 {
69 if (stripos($matches[2], 'autocommit=off') !== FALSE)
70 {
71 $this->auto_commit = FALSE;
72 }
73 }
74 else
75 {
76 // If no port is defined by the user, use the default value
77 $this->port == '' OR $this->port = 33000;
78 }
79 }
Esen Sagynov2e087942011-08-09 23:35:01 -070080
81 /**
82 * Non-persistent database connection
83 *
Esen Sagynov2e087942011-08-09 23:35:01 -070084 * @return resource
85 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +020086 public function db_connect()
Esen Sagynov2e087942011-08-09 23:35:01 -070087 {
Andrey Andreeva00e5042012-03-26 12:23:13 +030088 return $this->_cubrid_connect();
Esen Sagynov2e087942011-08-09 23:35:01 -070089 }
90
91 // --------------------------------------------------------------------
92
93 /**
94 * Persistent database connection
Andrey Andreev592f4ec2012-03-20 15:10:08 +020095 *
Esen Sagynov2e087942011-08-09 23:35:01 -070096 * In CUBRID persistent DB connection is supported natively in CUBRID
97 * engine which can be configured in the CUBRID Broker configuration
98 * file by setting the CCI_PCONNECT parameter to ON. In that case, all
99 * connections established between the client application and the
Andrey Andreeva00e5042012-03-26 12:23:13 +0300100 * server will become persistent.
Esen Sagynov2e087942011-08-09 23:35:01 -0700101 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700102 * @return resource
103 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200104 public function db_pconnect()
Esen Sagynov2e087942011-08-09 23:35:01 -0700105 {
Andrey Andreeva00e5042012-03-26 12:23:13 +0300106 return $this->_cubrid_connect(TRUE);
107 }
108
109 // --------------------------------------------------------------------
110
111 /**
112 * CUBRID connection
113 *
114 * A CUBRID-specific method to create a connection to the database.
115 * Except for determining if a persistent connection should be used,
116 * the rest of the logic is the same for db_connect() and db_pconnect().
117 *
118 * @param bool
119 * @return resource
120 */
121 protected function _cubrid_connect($persistent = FALSE)
122 {
123 if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
124 {
125 $_temp = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
126 $conn_id = ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
127 ? $_temp($this->dsn, $this->username, $this->password)
128 : $_temp($this->dsn);
129 }
130 else
131 {
132 $_temp = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
133 $conn_id = ($this->username !== '')
134 ? $_temp($this->hostname, $this->port, $this->database, $this->username, $this->password)
135 : $_temp($this->hostname, $this->port, $this->database);
136 }
137
138 return $conn_id;
Esen Sagynov2e087942011-08-09 23:35:01 -0700139 }
140
141 // --------------------------------------------------------------------
142
143 /**
144 * Reconnect
145 *
146 * Keep / reestablish the db connection if no queries have been
147 * sent for a length of time exceeding the server's idle timeout
148 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700149 * @return void
150 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200151 public function reconnect()
Esen Sagynov2e087942011-08-09 23:35:01 -0700152 {
153 if (cubrid_ping($this->conn_id) === FALSE)
154 {
155 $this->conn_id = FALSE;
156 }
157 }
158
159 // --------------------------------------------------------------------
160
161 /**
Andrey Andreev08856b82012-03-03 03:19:28 +0200162 * Database version number
Esen Sagynov2e087942011-08-09 23:35:01 -0700163 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700164 * @return string
165 */
Andrey Andreev08856b82012-03-03 03:19:28 +0200166 public function version()
Esen Sagynov2e087942011-08-09 23:35:01 -0700167 {
Andrey Andreev08856b82012-03-03 03:19:28 +0200168 return isset($this->data_cache['version'])
169 ? $this->data_cache['version']
170 : $this->data_cache['version'] = cubrid_get_server_info($this->conn_id);
Esen Sagynov2e087942011-08-09 23:35:01 -0700171 }
172
173 // --------------------------------------------------------------------
174
175 /**
176 * Execute the query
177 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700178 * @param string an SQL query
179 * @return resource
180 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200181 protected function _execute($sql)
Esen Sagynov2e087942011-08-09 23:35:01 -0700182 {
Esen Sagynov2e087942011-08-09 23:35:01 -0700183 return @cubrid_query($sql, $this->conn_id);
184 }
185
186 // --------------------------------------------------------------------
187
188 /**
Esen Sagynov2e087942011-08-09 23:35:01 -0700189 * Begin Transaction
190 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700191 * @return bool
192 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200193 public function trans_begin($test_mode = FALSE)
Esen Sagynov2e087942011-08-09 23:35:01 -0700194 {
Esen Sagynov2e087942011-08-09 23:35:01 -0700195 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev7f55d612012-01-26 13:44:28 +0200196 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Esen Sagynov2e087942011-08-09 23:35:01 -0700197 {
198 return TRUE;
199 }
200
201 // Reset the transaction failure flag.
202 // If the $test_mode flag is set to TRUE transactions will be rolled back
203 // even if the queries produce a successful result.
Andrey Andreev7f55d612012-01-26 13:44:28 +0200204 $this->_trans_failure = ($test_mode === TRUE);
Esen Sagynov2e087942011-08-09 23:35:01 -0700205
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700206 if (cubrid_get_autocommit($this->conn_id))
207 {
208 cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
209 }
Esen Sagynov2e087942011-08-09 23:35:01 -0700210
211 return TRUE;
212 }
213
214 // --------------------------------------------------------------------
215
216 /**
217 * Commit Transaction
218 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700219 * @return bool
220 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200221 public function trans_commit()
Esen Sagynov2e087942011-08-09 23:35:01 -0700222 {
Esen Sagynov2e087942011-08-09 23:35:01 -0700223 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev7f55d612012-01-26 13:44:28 +0200224 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Esen Sagynov2e087942011-08-09 23:35:01 -0700225 {
226 return TRUE;
227 }
228
229 cubrid_commit($this->conn_id);
230
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700231 if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
232 {
233 cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
234 }
235
Esen Sagynov2e087942011-08-09 23:35:01 -0700236 return TRUE;
237 }
238
239 // --------------------------------------------------------------------
240
241 /**
242 * Rollback Transaction
243 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700244 * @return bool
245 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200246 public function trans_rollback()
Esen Sagynov2e087942011-08-09 23:35:01 -0700247 {
Esen Sagynov2e087942011-08-09 23:35:01 -0700248 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev7f55d612012-01-26 13:44:28 +0200249 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Esen Sagynov2e087942011-08-09 23:35:01 -0700250 {
251 return TRUE;
252 }
253
254 cubrid_rollback($this->conn_id);
255
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700256 if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
257 {
258 cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
259 }
260
Esen Sagynov2e087942011-08-09 23:35:01 -0700261 return TRUE;
262 }
263
264 // --------------------------------------------------------------------
265
266 /**
267 * Escape String
268 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700269 * @param string
270 * @param bool whether or not the string will be used in a LIKE condition
271 * @return string
272 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200273 public function escape_str($str, $like = FALSE)
Esen Sagynov2e087942011-08-09 23:35:01 -0700274 {
275 if (is_array($str))
276 {
277 foreach ($str as $key => $val)
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700278 {
Esen Sagynov2e087942011-08-09 23:35:01 -0700279 $str[$key] = $this->escape_str($val, $like);
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700280 }
Esen Sagynov2e087942011-08-09 23:35:01 -0700281
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700282 return $str;
283 }
Esen Sagynov2e087942011-08-09 23:35:01 -0700284
Andrey Andreev394a3f12012-02-15 14:35:11 +0200285 if (function_exists('cubrid_real_escape_string') &&
286 (is_resource($this->conn_id)
287 OR (get_resource_type($this->conn_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->conn_id)))))
Esen Sagynov2e087942011-08-09 23:35:01 -0700288 {
289 $str = cubrid_real_escape_string($str, $this->conn_id);
290 }
291 else
292 {
293 $str = addslashes($str);
294 }
295
296 // escape LIKE condition wildcards
297 if ($like === TRUE)
298 {
Andrey Andreev7f55d612012-01-26 13:44:28 +0200299 return str_replace(array('%', '_'), array('\\%', '\\_'), $str);
Esen Sagynov2e087942011-08-09 23:35:01 -0700300 }
301
302 return $str;
303 }
304
305 // --------------------------------------------------------------------
306
307 /**
308 * Affected Rows
309 *
Andrey Andreevea3eec92012-03-01 19:16:23 +0200310 * @return int
Esen Sagynov2e087942011-08-09 23:35:01 -0700311 */
Andrey Andreevea3eec92012-03-01 19:16:23 +0200312 public function affected_rows()
Esen Sagynov2e087942011-08-09 23:35:01 -0700313 {
Andrey Andreevea3eec92012-03-01 19:16:23 +0200314 return @cubrid_affected_rows();
Esen Sagynov2e087942011-08-09 23:35:01 -0700315 }
316
317 // --------------------------------------------------------------------
318
319 /**
320 * Insert ID
321 *
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200322 * @return int
Esen Sagynov2e087942011-08-09 23:35:01 -0700323 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200324 public function insert_id()
Esen Sagynov2e087942011-08-09 23:35:01 -0700325 {
326 return @cubrid_insert_id($this->conn_id);
327 }
328
329 // --------------------------------------------------------------------
330
331 /**
332 * "Count All" query
333 *
334 * Generates a platform-specific query string that counts all records in
335 * the specified table
336 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700337 * @param string
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200338 * @return int
Esen Sagynov2e087942011-08-09 23:35:01 -0700339 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200340 public function count_all($table = '')
Esen Sagynov2e087942011-08-09 23:35:01 -0700341 {
342 if ($table == '')
343 {
344 return 0;
345 }
Esen Sagynov2e087942011-08-09 23:35:01 -0700346
Andrey Andreev032e7ea2012-03-06 19:48:35 +0200347 $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
Esen Sagynov2e087942011-08-09 23:35:01 -0700348 if ($query->num_rows() == 0)
349 {
350 return 0;
351 }
352
Andrey Andreev7f55d612012-01-26 13:44:28 +0200353 $query = $query->row();
Greg Aker90248ab2011-08-20 14:23:14 -0500354 $this->_reset_select();
Andrey Andreev7f55d612012-01-26 13:44:28 +0200355 return (int) $query->numrows;
Esen Sagynov2e087942011-08-09 23:35:01 -0700356 }
357
358 // --------------------------------------------------------------------
359
360 /**
361 * List table query
362 *
363 * Generates a platform-specific query string so that the table names can be fetched
364 *
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200365 * @param bool
Esen Sagynov2e087942011-08-09 23:35:01 -0700366 * @return string
367 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200368 protected function _list_tables($prefix_limit = FALSE)
Esen Sagynov2e087942011-08-09 23:35:01 -0700369 {
Andrey Andreev7f55d612012-01-26 13:44:28 +0200370 $sql = 'SHOW TABLES';
Esen Sagynov2e087942011-08-09 23:35:01 -0700371
Andrey Andreev7f55d612012-01-26 13:44:28 +0200372 if ($prefix_limit !== FALSE && $this->dbprefix != '')
Esen Sagynov2e087942011-08-09 23:35:01 -0700373 {
Andrey Andreev7f55d612012-01-26 13:44:28 +0200374 return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
Esen Sagynov2e087942011-08-09 23:35:01 -0700375 }
376
377 return $sql;
378 }
379
380 // --------------------------------------------------------------------
381
382 /**
383 * Show column query
384 *
385 * Generates a platform-specific query string so that the column names can be fetched
386 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700387 * @param string the table name
388 * @return string
389 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200390 protected function _list_columns($table = '')
Esen Sagynov2e087942011-08-09 23:35:01 -0700391 {
Andrey Andreev032e7ea2012-03-06 19:48:35 +0200392 return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
Esen Sagynov2e087942011-08-09 23:35:01 -0700393 }
394
395 // --------------------------------------------------------------------
396
397 /**
398 * Field data query
399 *
400 * Generates a platform-specific query so that the column data can be retrieved
401 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700402 * @param string the table name
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200403 * @return string
Esen Sagynov2e087942011-08-09 23:35:01 -0700404 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200405 protected function _field_data($table)
Esen Sagynov2e087942011-08-09 23:35:01 -0700406 {
Andrey Andreev7f55d612012-01-26 13:44:28 +0200407 return 'SELECT * FROM '.$table.' LIMIT 1';
Esen Sagynov2e087942011-08-09 23:35:01 -0700408 }
409
410 // --------------------------------------------------------------------
411
412 /**
Andrey Andreev4be5de12012-03-02 15:45:41 +0200413 * Error
Esen Sagynov2e087942011-08-09 23:35:01 -0700414 *
Andrey Andreev4be5de12012-03-02 15:45:41 +0200415 * Returns an array containing code and message of the last
416 * database error that has occured.
Esen Sagynov2e087942011-08-09 23:35:01 -0700417 *
Andrey Andreev4be5de12012-03-02 15:45:41 +0200418 * @return array
Esen Sagynov2e087942011-08-09 23:35:01 -0700419 */
Andrey Andreev4be5de12012-03-02 15:45:41 +0200420 public function error()
Esen Sagynov2e087942011-08-09 23:35:01 -0700421 {
Andrey Andreev4be5de12012-03-02 15:45:41 +0200422 return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id));
Esen Sagynov2e087942011-08-09 23:35:01 -0700423 }
424
Esen Sagynov2e087942011-08-09 23:35:01 -0700425 // --------------------------------------------------------------------
426
427 /**
428 * From Tables
429 *
430 * This function implicitly groups FROM tables so there is no confusion
431 * about operator precedence in harmony with SQL standards
432 *
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200433 * @param array
434 * @return string
Esen Sagynov2e087942011-08-09 23:35:01 -0700435 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200436 protected function _from_tables($tables)
Esen Sagynov2e087942011-08-09 23:35:01 -0700437 {
438 if ( ! is_array($tables))
439 {
440 $tables = array($tables);
441 }
442
443 return '('.implode(', ', $tables).')';
444 }
445
446 // --------------------------------------------------------------------
447
448 /**
Esen Sagynov2e087942011-08-09 23:35:01 -0700449 * Update_Batch statement
450 *
451 * Generates a platform-specific batch update string from the supplied data
452 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700453 * @param string the table name
454 * @param array the update data
455 * @param array the where clause
456 * @return string
457 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200458 protected function _update_batch($table, $values, $index, $where = NULL)
Esen Sagynov2e087942011-08-09 23:35:01 -0700459 {
460 $ids = array();
Esen Sagynov2e087942011-08-09 23:35:01 -0700461 foreach ($values as $key => $val)
462 {
463 $ids[] = $val[$index];
464
465 foreach (array_keys($val) as $field)
466 {
467 if ($field != $index)
468 {
Esen Sagynov2ab2b1e2011-08-11 00:41:16 -0700469 $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
Esen Sagynov2e087942011-08-09 23:35:01 -0700470 }
471 }
472 }
473
Esen Sagynov2e087942011-08-09 23:35:01 -0700474 $cases = '';
Esen Sagynov2e087942011-08-09 23:35:01 -0700475 foreach ($final as $k => $v)
476 {
Andrey Andreev7f55d612012-01-26 13:44:28 +0200477 $cases .= $k." = CASE \n"
478 .implode("\n", $v)
479 .'ELSE '.$k.' END, ';
Esen Sagynov2e087942011-08-09 23:35:01 -0700480 }
481
Andrey Andreev2e430a32012-02-12 23:37:58 +0200482 return 'UPDATE '.$table.' SET '.substr($cases, 0, -2)
Andrey Andreev7f55d612012-01-26 13:44:28 +0200483 .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '')
484 .$index.' IN ('.implode(',', $ids).')';
Esen Sagynov2e087942011-08-09 23:35:01 -0700485 }
486
487 // --------------------------------------------------------------------
Andrey Andreev79922c02012-05-23 12:27:17 +0300488
Esen Sagynov2e087942011-08-09 23:35:01 -0700489 /**
490 * Limit string
491 *
492 * Generates a platform-specific LIMIT clause
493 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700494 * @param string the sql query string
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200495 * @param int the number of rows to limit the query to
496 * @param int the offset value
Esen Sagynov2e087942011-08-09 23:35:01 -0700497 * @return string
498 */
Andrey Andreev592f4ec2012-03-20 15:10:08 +0200499 protected function _limit($sql, $limit, $offset)
Esen Sagynov2e087942011-08-09 23:35:01 -0700500 {
Andrey Andreevc6953f42012-01-26 14:43:16 +0200501 return $sql.'LIMIT '.($offset == 0 ? '' : $offset.', ').$limit;
Esen Sagynov2e087942011-08-09 23:35:01 -0700502 }
503
504 // --------------------------------------------------------------------
505
506 /**
507 * Close DB Connection
508 *
Esen Sagynov2e087942011-08-09 23:35:01 -0700509 * @return void
510 */
Andrey Andreev79922c02012-05-23 12:27:17 +0300511 protected function _close()
Esen Sagynov2e087942011-08-09 23:35:01 -0700512 {
Andrey Andreev79922c02012-05-23 12:27:17 +0300513 @cubrid_close($this->conn_id);
Esen Sagynov2e087942011-08-09 23:35:01 -0700514 }
515
516}
517
Esen Sagynov2e087942011-08-09 23:35:01 -0700518/* End of file cubrid_driver.php */
Andrey Andreev79922c02012-05-23 12:27:17 +0300519/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */