

Public Member Functions | |
| CI_DB_odbc_driver () | |
| db_connect () | |
| Non-persistent database connection. | |
| db_pconnect () | |
| Persistent database connection. | |
| db_select () | |
| Select the database. | |
| db_set_charset ($charset, $collation) | |
| Set client character set. | |
| _version () | |
| Version number query string. | |
| _execute ($sql) | |
| Execute the query. | |
| _prep_query ($sql) | |
| Prep the query. | |
| trans_begin ($test_mode=FALSE) | |
| Begin Transaction. | |
| trans_commit () | |
| Commit Transaction. | |
| trans_rollback () | |
| Rollback Transaction. | |
| escape_str ($str) | |
| Escape String. | |
| affected_rows () | |
| Affected Rows. | |
| insert_id () | |
| Insert ID. | |
| count_all ($table= '') | |
| "Count All" query | |
| _list_tables ($prefix_limit=FALSE) | |
| Show table query. | |
| _list_columns ($table= '') | |
| Show column query. | |
| _field_data ($table) | |
| Field data query. | |
| _error_message () | |
| The error message string. | |
| _error_number () | |
| The error message number. | |
| _escape_table ($table) | |
| Escape Table Name. | |
| _protect_identifiers ($item, $first_word_only=FALSE) | |
| Protect Identifiers. | |
| _from_tables ($tables) | |
| From Tables. | |
| _insert ($table, $keys, $values) | |
| Insert statement. | |
| _update ($table, $values, $where, $orderby=array(), $limit=FALSE) | |
| Update statement. | |
| _truncate ($table) | |
| Truncate statement. | |
| _delete ($table, $where=array(), $like=array(), $limit=FALSE) | |
| Delete statement. | |
| _limit ($sql, $limit, $offset) | |
| Limit string. | |
| _close ($conn_id) | |
| Close DB Connection. | |
Public Attributes | |
| $_count_string = "SELECT COUNT(*) AS " | |
| The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions. | |
| $_random_keyword | |
Definition at line 31 of file odbc_driver.php.
| CI_DB_odbc_driver::_close | ( | $ | conn_id | ) |
Close DB Connection.
public
| resource |
Definition at line 607 of file odbc_driver.php.
| CI_DB_odbc_driver::_delete | ( | $ | table, | |
| $ | where = array(), |
|||
| $ | like = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Delete statement.
Generates a platform-specific delete string from the supplied data
public
| string | the table name | |
| array | the where clause | |
| string | the limit clause |
Definition at line 558 of file odbc_driver.php.
Referenced by _truncate().
00559 { 00560 $conditions = ''; 00561 00562 if (count($where) > 0 OR count($like) > 0) 00563 { 00564 $conditions = "\nWHERE "; 00565 $conditions .= implode("\n", $this->ar_where); 00566 00567 if (count($where) > 0 && count($like) > 0) 00568 { 00569 $conditions .= " AND "; 00570 } 00571 $conditions .= implode("\n", $like); 00572 } 00573 00574 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00575 00576 return "DELETE FROM ".$table.$conditions.$limit; 00577 }

| CI_DB_odbc_driver::_error_message | ( | ) |
| CI_DB_odbc_driver::_error_number | ( | ) |
| CI_DB_odbc_driver::_escape_table | ( | $ | table | ) |
Escape Table Name.
This function adds backticks if the table name has a period in it. Some DBs will get cranky unless periods are escaped
private
| string | the table name |
Definition at line 387 of file odbc_driver.php.
| CI_DB_odbc_driver::_execute | ( | $ | sql | ) |
Execute the query.
private called by the base class
| string | an SQL query |
Definition at line 123 of file odbc_driver.php.
References _prep_query().
00124 { 00125 $sql = $this->_prep_query($sql); 00126 return @odbc_exec($this->conn_id, $sql); 00127 }

| CI_DB_odbc_driver::_field_data | ( | $ | table | ) |
Field data query.
Generates a platform-specific query so that the column data can be retrieved
public
| string | the table name |
Definition at line 344 of file odbc_driver.php.
| CI_DB_odbc_driver::_from_tables | ( | $ | tables | ) |
From Tables.
This function implicitly groups FROM tables so there is no confusion about operator precedence in harmony with SQL standards
public
| type |
Definition at line 465 of file odbc_driver.php.
00466 { 00467 if ( ! is_array($tables)) 00468 { 00469 $tables = array($tables); 00470 } 00471 00472 return '('.implode(', ', $tables).')'; 00473 }
| CI_DB_odbc_driver::_insert | ( | $ | table, | |
| $ | keys, | |||
| $ | values | |||
| ) |
Insert statement.
Generates a platform-specific insert string from the supplied data
public
| string | the table name | |
| array | the insert keys | |
| array | the insert values |
Definition at line 488 of file odbc_driver.php.
00489 { 00490 return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; 00491 }
| CI_DB_odbc_driver::_limit | ( | $ | sql, | |
| $ | limit, | |||
| $ | offset | |||
| ) |
Limit string.
Generates a platform-specific LIMIT clause
public
| string | the sql query string | |
| integer | the number of rows to limit the query to | |
| integer | the offset value |
Definition at line 592 of file odbc_driver.php.
| CI_DB_odbc_driver::_list_columns | ( | $ | table = '' |
) |
Show column query.
Generates a platform-specific query string so that the column names can be fetched
public
| string | the table name |
Definition at line 328 of file odbc_driver.php.
| CI_DB_odbc_driver::_list_tables | ( | $ | prefix_limit = FALSE |
) |
Show table query.
Generates a platform-specific query string so that the table names can be fetched
private
| boolean |
Definition at line 304 of file odbc_driver.php.
00305 { 00306 $sql = "SHOW TABLES FROM `".$this->database."`"; 00307 00308 if ($prefix_limit !== FALSE AND $this->dbprefix != '') 00309 { 00310 //$sql .= " LIKE '".$this->dbprefix."%'"; 00311 return FALSE; // not currently supported 00312 } 00313 00314 return $sql; 00315 }
| CI_DB_odbc_driver::_prep_query | ( | $ | sql | ) |
Prep the query.
If needed, each database adapter can prep the query string
private called by execute()
| string | an SQL query |
Definition at line 140 of file odbc_driver.php.
Referenced by _execute().

| CI_DB_odbc_driver::_protect_identifiers | ( | $ | item, | |
| $ | first_word_only = FALSE | |||
| ) |
Protect Identifiers.
This function adds backticks if appropriate based on db type
private
| mixed | the item to escape | |
| boolean | only affect the first word |
Definition at line 405 of file odbc_driver.php.
Referenced by count_all().
00406 { 00407 if (is_array($item)) 00408 { 00409 $escaped_array = array(); 00410 00411 foreach($item as $k=>$v) 00412 { 00413 $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only); 00414 } 00415 00416 return $escaped_array; 00417 } 00418 00419 // This function may get "item1 item2" as a string, and so 00420 // we may need "`item1` `item2`" and not "`item1 item2`" 00421 if (ctype_alnum($item) === FALSE) 00422 { 00423 if (strpos($item, '.') !== FALSE) 00424 { 00425 $aliased_tables = implode(".",$this->ar_aliased_tables).'.'; 00426 $table_name = substr($item, 0, strpos($item, '.')+1); 00427 $item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item; 00428 } 00429 00430 // This function may get "field >= 1", and need it to return "`field` >= 1" 00431 $lbound = ($first_word_only === TRUE) ? '' : '|\s|\('; 00432 00433 $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1`$2`$3', $item); 00434 } 00435 else 00436 { 00437 return "{$item}"; 00438 } 00439 00440 $exceptions = array('AS', '/', '-', '%', '+', '*', 'OR', 'IS'); 00441 00442 foreach ($exceptions as $exception) 00443 { 00444 00445 if (stristr($item, " {$exception} ") !== FALSE) 00446 { 00447 $item = preg_replace('/ ('.preg_quote($exception).') /i', ' $1 ', $item); 00448 } 00449 } 00450 return $item; 00451 }

| CI_DB_odbc_driver::_truncate | ( | $ | table | ) |
Truncate statement.
Generates a platform-specific truncate string from the supplied data If the database does not support the truncate() command This function maps to "DELETE FROM table"
public
| string | the table name |
Definition at line 540 of file odbc_driver.php.
References _delete().
00541 { 00542 return $this->_delete($table); 00543 }

| CI_DB_odbc_driver::_update | ( | $ | table, | |
| $ | values, | |||
| $ | where, | |||
| $ | orderby = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Update statement.
Generates a platform-specific update string from the supplied data
public
| string | the table name | |
| array | the update data | |
| array | the where clause | |
| array | the orderby clause | |
| array | the limit clause |
Definition at line 508 of file odbc_driver.php.
00509 { 00510 foreach($values as $key => $val) 00511 { 00512 $valstr[] = $key." = ".$val; 00513 } 00514 00515 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00516 00517 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; 00518 00519 $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr); 00520 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; 00521 $sql .= $orderby.$limit; 00522 00523 return $sql; 00524 }
| CI_DB_odbc_driver::_version | ( | ) |
| CI_DB_odbc_driver::affected_rows | ( | ) |
| CI_DB_odbc_driver::CI_DB_odbc_driver | ( | ) |
Definition at line 42 of file odbc_driver.php.
00043 { 00044 $this->_random_keyword = ' RND('.time().')'; // database specific random keyword 00045 }
| CI_DB_odbc_driver::count_all | ( | $ | table = '' |
) |
"Count All" query
Generates a platform-specific query string that counts all records in the specified database
public
| string |
Definition at line 279 of file odbc_driver.php.
References _protect_identifiers().
00280 { 00281 if ($table == '') 00282 return '0'; 00283 00284 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($this->dbprefix.$table)); 00285 00286 if ($query->num_rows() == 0) 00287 return '0'; 00288 00289 $row = $query->row(); 00290 return $row->numrows; 00291 }

| CI_DB_odbc_driver::db_connect | ( | ) |
Non-persistent database connection.
private called by the base class
Definition at line 53 of file odbc_driver.php.
| CI_DB_odbc_driver::db_pconnect | ( | ) |
Persistent database connection.
private called by the base class
Definition at line 66 of file odbc_driver.php.
| CI_DB_odbc_driver::db_select | ( | ) |
Select the database.
private called by the base class
Definition at line 79 of file odbc_driver.php.
| CI_DB_odbc_driver::db_set_charset | ( | $ | charset, | |
| $ | collation | |||
| ) |
Set client character set.
public
| string | ||
| string |
Definition at line 95 of file odbc_driver.php.
| CI_DB_odbc_driver::escape_str | ( | $ | str | ) |
Escape String.
public
| string |
Definition at line 235 of file odbc_driver.php.
| CI_DB_odbc_driver::insert_id | ( | ) |
| CI_DB_odbc_driver::trans_begin | ( | $ | test_mode = FALSE |
) |
Begin Transaction.
public
Definition at line 153 of file odbc_driver.php.
00154 { 00155 if ( ! $this->trans_enabled) 00156 { 00157 return TRUE; 00158 } 00159 00160 // When transactions are nested we only begin/commit/rollback the outermost ones 00161 if ($this->_trans_depth > 0) 00162 { 00163 return TRUE; 00164 } 00165 00166 // Reset the transaction failure flag. 00167 // If the $test_mode flag is set to TRUE transactions will be rolled back 00168 // even if the queries produce a successful result. 00169 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; 00170 00171 return odbc_autocommit($this->conn_id, FALSE); 00172 }
| CI_DB_odbc_driver::trans_commit | ( | ) |
Commit Transaction.
public
Definition at line 182 of file odbc_driver.php.
00183 { 00184 if ( ! $this->trans_enabled) 00185 { 00186 return TRUE; 00187 } 00188 00189 // When transactions are nested we only begin/commit/rollback the outermost ones 00190 if ($this->_trans_depth > 0) 00191 { 00192 return TRUE; 00193 } 00194 00195 $ret = odbc_commit($this->conn_id); 00196 odbc_autocommit($this->conn_id, TRUE); 00197 return $ret; 00198 }
| CI_DB_odbc_driver::trans_rollback | ( | ) |
Rollback Transaction.
public
Definition at line 208 of file odbc_driver.php.
00209 { 00210 if ( ! $this->trans_enabled) 00211 { 00212 return TRUE; 00213 } 00214 00215 // When transactions are nested we only begin/commit/rollback the outermost ones 00216 if ($this->_trans_depth > 0) 00217 { 00218 return TRUE; 00219 } 00220 00221 $ret = odbc_rollback($this->conn_id); 00222 odbc_autocommit($this->conn_id, TRUE); 00223 return $ret; 00224 }
| CI_DB_odbc_driver::$_count_string = "SELECT COUNT(*) AS " |
The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions.
Definition at line 38 of file odbc_driver.php.
| CI_DB_odbc_driver::$_random_keyword |
Definition at line 39 of file odbc_driver.php.