Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 1 | <?php |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Andrey Andreev | fe9309d | 2015-01-09 17:48:58 +0200 | [diff] [blame] | 5 | * An open source application development framework for PHP |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Andrey Andreev | bdb96ca | 2014-10-28 00:13:31 +0200 | [diff] [blame] | 7 | * This content is released under the MIT License (MIT) |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 8 | * |
Andrey Andreev | fe9309d | 2015-01-09 17:48:58 +0200 | [diff] [blame] | 9 | * Copyright (c) 2014 - 2015, British Columbia Institute of Technology |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 10 | * |
Andrey Andreev | bdb96ca | 2014-10-28 00:13:31 +0200 | [diff] [blame] | 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | * of this software and associated documentation files (the "Software"), to deal |
| 13 | * in the Software without restriction, including without limitation the rights |
| 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | * copies of the Software, and to permit persons to whom the Software is |
| 16 | * furnished to do so, subject to the following conditions: |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 17 | * |
Andrey Andreev | bdb96ca | 2014-10-28 00:13:31 +0200 | [diff] [blame] | 18 | * The above copyright notice and this permission notice shall be included in |
| 19 | * all copies or substantial portions of the Software. |
| 20 | * |
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 27 | * THE SOFTWARE. |
| 28 | * |
| 29 | * @package CodeIgniter |
| 30 | * @author EllisLab Dev Team |
darwinel | 871754a | 2014-02-11 17:34:57 +0100 | [diff] [blame] | 31 | * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) |
Andrey Andreev | fe9309d | 2015-01-09 17:48:58 +0200 | [diff] [blame] | 32 | * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) |
Andrey Andreev | bdb96ca | 2014-10-28 00:13:31 +0200 | [diff] [blame] | 33 | * @license http://opensource.org/licenses/MIT MIT License |
| 34 | * @link http://codeigniter.com |
| 35 | * @since Version 1.3.0 |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 36 | * @filesource |
| 37 | */ |
Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 38 | defined('BASEPATH') OR exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 39 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 40 | /** |
| 41 | * ODBC Database Adapter Class |
| 42 | * |
| 43 | * Note: _DB is an extender class that the app controller |
Jamie Rumbelow | 7efad20 | 2012-02-19 12:37:00 +0000 | [diff] [blame] | 44 | * creates dynamically based on whether the query builder |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 45 | * class is being used or not. |
| 46 | * |
| 47 | * @package CodeIgniter |
| 48 | * @subpackage Drivers |
| 49 | * @category Database |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 50 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 51 | * @link http://codeigniter.com/user_guide/database/ |
| 52 | */ |
| 53 | class CI_DB_odbc_driver extends CI_DB { |
| 54 | |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 55 | /** |
| 56 | * Database driver |
| 57 | * |
| 58 | * @var string |
| 59 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 60 | public $dbdriver = 'odbc'; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 61 | |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 62 | /** |
Andrey Andreev | 3e9d2b8 | 2012-10-27 14:28:51 +0300 | [diff] [blame] | 63 | * Database schema |
| 64 | * |
| 65 | * @var string |
Andrey Andreev | 485a348 | 2012-10-27 03:22:43 +0300 | [diff] [blame] | 66 | */ |
| 67 | public $schema = 'public'; |
| 68 | |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 69 | // -------------------------------------------------------------------- |
| 70 | |
Andrey Andreev | 485a348 | 2012-10-27 03:22:43 +0300 | [diff] [blame] | 71 | /** |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 72 | * Identifier escape character |
| 73 | * |
| 74 | * Must be empty for ODBC. |
| 75 | * |
| 76 | * @var string |
| 77 | */ |
| 78 | protected $_escape_char = ''; |
| 79 | |
| 80 | /** |
| 81 | * ESCAPE statement string |
| 82 | * |
| 83 | * @var string |
| 84 | */ |
| 85 | protected $_like_escape_str = " {escape '%s'} "; |
| 86 | |
Andrey Andreev | 98e46cf | 2012-11-13 03:01:42 +0200 | [diff] [blame] | 87 | /** |
| 88 | * ORDER BY random keyword |
| 89 | * |
| 90 | * @var array |
| 91 | */ |
| 92 | protected $_random_keyword = array('RND()', 'RND(%d)'); |
| 93 | |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 94 | // -------------------------------------------------------------------- |
| 95 | |
| 96 | /** |
| 97 | * Class constructor |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 98 | * |
| 99 | * @param array $params |
| 100 | * @return void |
| 101 | */ |
Andrey Andreev | 5f356bf | 2012-03-20 14:32:27 +0200 | [diff] [blame] | 102 | public function __construct($params) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 103 | { |
Timothy Warren | a2097a0 | 2011-10-10 10:10:46 -0400 | [diff] [blame] | 104 | parent::__construct($params); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 105 | |
Andrey Andreev | 46f6dbc | 2012-02-13 01:39:53 +0200 | [diff] [blame] | 106 | // Legacy support for DSN in the hostname field |
Andrey Andreev | e4c3019 | 2012-06-04 15:08:24 +0300 | [diff] [blame] | 107 | if (empty($this->dsn)) |
Andrey Andreev | 46f6dbc | 2012-02-13 01:39:53 +0200 | [diff] [blame] | 108 | { |
| 109 | $this->dsn = $this->hostname; |
| 110 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 113 | // -------------------------------------------------------------------- |
| 114 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 115 | /** |
| 116 | * Non-persistent database connection |
| 117 | * |
Andrey Andreev | 2e17102 | 2014-02-25 15:21:41 +0200 | [diff] [blame] | 118 | * @param bool $persistent |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 119 | * @return resource |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 120 | */ |
Andrey Andreev | 2e17102 | 2014-02-25 15:21:41 +0200 | [diff] [blame] | 121 | public function db_connect($persistent = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 122 | { |
Andrey Andreev | 2e17102 | 2014-02-25 15:21:41 +0200 | [diff] [blame] | 123 | return ($persistent === TRUE) |
| 124 | ? odbc_pconnect($this->dsn, $this->username, $this->password) |
| 125 | : odbc_connect($this->dsn, $this->username, $this->password); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 126 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 127 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 128 | // -------------------------------------------------------------------- |
| 129 | |
| 130 | /** |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 131 | * Execute the query |
| 132 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 133 | * @param string $sql an SQL query |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 134 | * @return resource |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 135 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 136 | protected function _execute($sql) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 137 | { |
Andrey Andreev | 2bbbd1a | 2014-05-09 10:24:14 +0300 | [diff] [blame] | 138 | return odbc_exec($this->conn_id, $sql); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | // -------------------------------------------------------------------- |
| 142 | |
| 143 | /** |
| 144 | * Begin Transaction |
| 145 | * |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 146 | * @return bool |
| 147 | */ |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 148 | protected function _trans_begin() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 149 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 150 | return odbc_autocommit($this->conn_id, FALSE); |
| 151 | } |
| 152 | |
| 153 | // -------------------------------------------------------------------- |
| 154 | |
| 155 | /** |
| 156 | * Commit Transaction |
| 157 | * |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 158 | * @return bool |
| 159 | */ |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 160 | protected function _trans_commit() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 161 | { |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 162 | if (odbc_commit($this->conn_id)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 163 | { |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 164 | odbc_autocommit($this->conn_id, TRUE); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 165 | return TRUE; |
| 166 | } |
| 167 | |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 168 | return FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | // -------------------------------------------------------------------- |
| 172 | |
| 173 | /** |
| 174 | * Rollback Transaction |
| 175 | * |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 176 | * @return bool |
| 177 | */ |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 178 | protected function _trans_rollback() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 179 | { |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 180 | if (odbc_rollback($this->conn_id)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 181 | { |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 182 | odbc_autocommit($this->conn_id, TRUE); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 183 | return TRUE; |
| 184 | } |
| 185 | |
Andrey Andreev | a7d4aba | 2015-10-19 14:39:44 +0300 | [diff] [blame^] | 186 | return FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | // -------------------------------------------------------------------- |
| 190 | |
| 191 | /** |
Andrey Andreev | 0b6a492 | 2013-01-10 16:53:44 +0200 | [diff] [blame] | 192 | * Platform-dependant string escape |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 193 | * |
Andrey Andreev | 0b6a492 | 2013-01-10 16:53:44 +0200 | [diff] [blame] | 194 | * @param string |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 195 | * @return string |
| 196 | */ |
Andrey Andreev | 0b6a492 | 2013-01-10 16:53:44 +0200 | [diff] [blame] | 197 | protected function _escape_str($str) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 198 | { |
Andrey Andreev | 0b6a492 | 2013-01-10 16:53:44 +0200 | [diff] [blame] | 199 | return remove_invisible_characters($str); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 200 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 201 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 202 | // -------------------------------------------------------------------- |
| 203 | |
| 204 | /** |
| 205 | * Affected Rows |
| 206 | * |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 207 | * @return int |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 208 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 209 | public function affected_rows() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 210 | { |
Andrey Andreev | 2bbbd1a | 2014-05-09 10:24:14 +0300 | [diff] [blame] | 211 | return odbc_num_rows($this->result_id); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 212 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 213 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 214 | // -------------------------------------------------------------------- |
| 215 | |
| 216 | /** |
| 217 | * Insert ID |
| 218 | * |
Andrey Andreev | 8af7666 | 2012-03-05 14:33:41 +0200 | [diff] [blame] | 219 | * @return bool |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 220 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 221 | public function insert_id() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 222 | { |
Andrey Andreev | 8d3afde | 2012-11-06 12:53:47 +0200 | [diff] [blame] | 223 | return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // -------------------------------------------------------------------- |
| 227 | |
| 228 | /** |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 229 | * Show table query |
| 230 | * |
| 231 | * Generates a platform-specific query string so that the table names can be fetched |
| 232 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 233 | * @param bool $prefix_limit |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 234 | * @return string |
| 235 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 236 | protected function _list_tables($prefix_limit = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 237 | { |
Andrey Andreev | 485a348 | 2012-10-27 03:22:43 +0300 | [diff] [blame] | 238 | $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 239 | |
Andrey Andreev | e4c3019 | 2012-06-04 15:08:24 +0300 | [diff] [blame] | 240 | if ($prefix_limit !== FALSE && $this->dbprefix !== '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 241 | { |
Andrey Andreev | 485a348 | 2012-10-27 03:22:43 +0300 | [diff] [blame] | 242 | return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' " |
| 243 | .sprintf($this->_like_escape_str, $this->_like_escape_chr); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 244 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 245 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 246 | return $sql; |
| 247 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 248 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 249 | // -------------------------------------------------------------------- |
| 250 | |
| 251 | /** |
| 252 | * Show column query |
| 253 | * |
| 254 | * Generates a platform-specific query string so that the column names can be fetched |
| 255 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 256 | * @param string $table |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 257 | * @return string |
| 258 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 259 | protected function _list_columns($table = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 260 | { |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 261 | return 'SHOW COLUMNS FROM '.$table; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | // -------------------------------------------------------------------- |
| 265 | |
| 266 | /** |
| 267 | * Field data query |
| 268 | * |
| 269 | * Generates a platform-specific query so that the column data can be retrieved |
| 270 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 271 | * @param string $table |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 272 | * @return string |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 273 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 274 | protected function _field_data($table) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 275 | { |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 276 | return 'SELECT TOP 1 FROM '.$table; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | // -------------------------------------------------------------------- |
| 280 | |
| 281 | /** |
Andrey Andreev | 4be5de1 | 2012-03-02 15:45:41 +0200 | [diff] [blame] | 282 | * Error |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 283 | * |
Andrey Andreev | 4be5de1 | 2012-03-02 15:45:41 +0200 | [diff] [blame] | 284 | * Returns an array containing code and message of the last |
| 285 | * database error that has occured. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 286 | * |
Andrey Andreev | 4be5de1 | 2012-03-02 15:45:41 +0200 | [diff] [blame] | 287 | * @return array |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 288 | */ |
Andrey Andreev | 4be5de1 | 2012-03-02 15:45:41 +0200 | [diff] [blame] | 289 | public function error() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 290 | { |
Andrey Andreev | 4be5de1 | 2012-03-02 15:45:41 +0200 | [diff] [blame] | 291 | return array('code' => odbc_error($this->conn_id), 'message' => odbc_errormsg($this->conn_id)); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | // -------------------------------------------------------------------- |
| 295 | |
| 296 | /** |
Andrey Andreev | b047865 | 2012-07-18 15:34:46 +0300 | [diff] [blame] | 297 | * Update statement |
| 298 | * |
| 299 | * Generates a platform-specific update string from the supplied data |
| 300 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 301 | * @param string $table |
| 302 | * @param array $values |
Andrey Andreev | b047865 | 2012-07-18 15:34:46 +0300 | [diff] [blame] | 303 | * @return string |
Andrey Andreev | 838a9d6 | 2012-12-03 14:37:47 +0200 | [diff] [blame] | 304 | */ |
Andrey Andreev | b047865 | 2012-07-18 15:34:46 +0300 | [diff] [blame] | 305 | protected function _update($table, $values) |
| 306 | { |
| 307 | $this->qb_limit = FALSE; |
| 308 | $this->qb_orderby = array(); |
| 309 | return parent::_update($table, $values); |
| 310 | } |
| 311 | |
| 312 | // -------------------------------------------------------------------- |
| 313 | |
| 314 | /** |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 315 | * Truncate statement |
| 316 | * |
| 317 | * Generates a platform-specific truncate string from the supplied data |
Andrey Andreev | a6fe36e | 2012-04-05 16:00:32 +0300 | [diff] [blame] | 318 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 319 | * If the database does not support the TRUNCATE statement, |
Andrey Andreev | a6fe36e | 2012-04-05 16:00:32 +0300 | [diff] [blame] | 320 | * then this method maps to 'DELETE FROM table' |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 321 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 322 | * @param string $table |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 323 | * @return string |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 324 | */ |
Andrey Andreev | b76029d | 2012-01-26 15:13:19 +0200 | [diff] [blame] | 325 | protected function _truncate($table) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 326 | { |
Andrey Andreev | a6fe36e | 2012-04-05 16:00:32 +0300 | [diff] [blame] | 327 | return 'DELETE FROM '.$table; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 328 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 329 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 330 | // -------------------------------------------------------------------- |
| 331 | |
| 332 | /** |
Andrey Andreev | b047865 | 2012-07-18 15:34:46 +0300 | [diff] [blame] | 333 | * Delete statement |
| 334 | * |
| 335 | * Generates a platform-specific delete string from the supplied data |
| 336 | * |
Andrey Andreev | a24e52e | 2012-11-02 03:54:12 +0200 | [diff] [blame] | 337 | * @param string $table |
Andrey Andreev | b047865 | 2012-07-18 15:34:46 +0300 | [diff] [blame] | 338 | * @return string |
| 339 | */ |
| 340 | protected function _delete($table) |
| 341 | { |
| 342 | $this->qb_limit = FALSE; |
| 343 | return parent::_delete($table); |
| 344 | } |
| 345 | |
| 346 | // -------------------------------------------------------------------- |
| 347 | |
| 348 | /** |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 349 | * Close DB Connection |
| 350 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 351 | * @return void |
| 352 | */ |
Andrey Andreev | 79922c0 | 2012-05-23 12:27:17 +0300 | [diff] [blame] | 353 | protected function _close() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 354 | { |
Andrey Andreev | 2bbbd1a | 2014-05-09 10:24:14 +0300 | [diff] [blame] | 355 | odbc_close($this->conn_id); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 358 | } |