Public Member Functions | |
| CI_DB_driver ($params) | |
| initialize () | |
| db_set_charset ($charset, $collation) | |
| platform () | |
| version () | |
| query ($sql, $binds=FALSE, $return_object=TRUE) | |
| load_rdriver () | |
| simple_query ($sql) | |
| trans_off () | |
| trans_strict ($mode=TRUE) | |
| trans_start ($test_mode=FALSE) | |
| trans_complete () | |
| trans_status () | |
| compile_binds ($sql, $binds) | |
| is_write_type ($sql) | |
| elapsed_time ($decimals=6) | |
| total_queries () | |
| last_query () | |
| escape ($str) | |
| primary ($table= '') | |
| list_tables ($constrain_by_prefix=FALSE) | |
| table_exists ($table_name) | |
| list_fields ($table= '') | |
| field_exists ($field_name, $table_name) | |
| field_data ($table= '') | |
| insert_string ($table, $data) | |
| update_string ($table, $data, $where) | |
| _has_operator ($str) | |
| call_function ($function) | |
| cache_set_path ($path= '') | |
| cache_on () | |
| cache_off () | |
| cache_delete ($segment_one= '', $segment_two= '') | |
| cache_delete_all () | |
| _cache_init () | |
| close () | |
| display_error ($error= '', $swap= '', $native=FALSE) | |
| protect_identifiers ($item, $prefix_single=FALSE) | |
| _protect_identifiers ($item, $prefix_single=FALSE, $protect_identifiers=NULL, $field_exists=TRUE) | |
Public Attributes | |
| $username | |
| $password | |
| $hostname | |
| $database | |
| $dbdriver = 'mysql' | |
| $dbprefix = '' | |
| $char_set = 'utf8' | |
| $dbcollat = 'utf8_general_ci' | |
| $autoinit = TRUE | |
| $swap_pre = '' | |
| $port = '' | |
| $pconnect = FALSE | |
| $conn_id = FALSE | |
| $result_id = FALSE | |
| $db_debug = FALSE | |
| $benchmark = 0 | |
| $query_count = 0 | |
| $bind_marker = '?' | |
| $save_queries = TRUE | |
| $queries = array() | |
| $query_times = array() | |
| $data_cache = array() | |
| $trans_enabled = TRUE | |
| $trans_strict = TRUE | |
| $_trans_depth = 0 | |
| $_trans_status = TRUE | |
| $cache_on = FALSE | |
| $cachedir = '' | |
| $cache_autodel = FALSE | |
| $CACHE | |
| $_protect_identifiers = TRUE | |
| $_reserved_identifiers = array('*') | |
| $stmt_id | |
| $curs_id | |
| $limit_used | |
| CI_DB_driver::_cache_init | ( | ) |
Initialize the Cache Class
private
| CI_DB_driver::_has_operator | ( | $ | str | ) |
Tests whether the string has an SQL operator
private
| string |
| CI_DB_driver::_protect_identifiers | ( | $ | item, | |
| $ | prefix_single = FALSE, |
|||
| $ | protect_identifiers = NULL, |
|||
| $ | field_exists = TRUE | |||
| ) |
Protect Identifiers
This function is used extensively by the Active Record class, and by a couple functions in this class. It takes a column or table name (optionally with an alias) and inserts the table prefix onto it. Some logic is necessary in order to deal with column names that include the path. Consider a query like this:
SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table
Or a query with aliasing:
SELECT m.member_id, m.member_name FROM members AS m
Since the column name can include up to four segments (host, DB, table, column) or also have an alias prefix, we need to do a bit of work to figure this out and insert the table prefix (if it exists) in the proper position, and escape only the correct identifiers.
private
| string | ||
| bool | ||
| mixed | ||
| bool |
| CI_DB_driver::cache_delete | ( | $ | segment_one = '', |
|
| $ | segment_two = '' | |||
| ) |
Delete the cache files associated with a particular URI
public
| CI_DB_driver::cache_delete_all | ( | ) |
Delete All cache files
public
| CI_DB_driver::cache_off | ( | ) |
Disable Query Caching
public
| CI_DB_driver::cache_on | ( | ) |
Enable Query Caching
public
| CI_DB_driver::cache_set_path | ( | $ | path = '' |
) |
Set Cache Directory Path
public
| string | the path to the cache directory |
| CI_DB_driver::call_function | ( | $ | function | ) |
Enables a native PHP function to be run, using a platform agnostic wrapper.
public
| string | the function name | |
| mixed | any parameters needed by the function |
| CI_DB_driver::CI_DB_driver | ( | $ | params | ) |
Constructor. Accepts one parameter containing the database connection settings.
| array |
| CI_DB_driver::close | ( | ) |
Close DB Connection
public
| CI_DB_driver::compile_binds | ( | $ | sql, | |
| $ | binds | |||
| ) |
Compile Bindings
public
| string | the sql statement | |
| array | an array of bind data |
| CI_DB_driver::db_set_charset | ( | $ | charset, | |
| $ | collation | |||
| ) |
Set client character set
public
| string | ||
| string |
| CI_DB_driver::display_error | ( | $ | error = '', |
|
| $ | swap = '', |
|||
| $ | native = FALSE | |||
| ) |
Display an error message
public
| string | the error message | |
| string | any "swap" values | |
| boolean | whether to localize the message |
| CI_DB_driver::elapsed_time | ( | $ | decimals = 6 |
) |
Calculate the aggregate query elapsed time
public
| integer | The number of decimal places |
| CI_DB_driver::escape | ( | $ | str | ) |
"Smart" Escape String
Escapes data based on type Sets boolean and null types
public
| string |
| CI_DB_driver::field_data | ( | $ | table = '' |
) |
Returns an object with field data
public
| string | the table name |
| CI_DB_driver::field_exists | ( | $ | field_name, | |
| $ | table_name | |||
| ) |
Determine if a particular field exists public
| string | ||
| string |
| CI_DB_driver::initialize | ( | ) |
Initialize Database Settings
private Called by the constructor
| mixed |
| CI_DB_driver::insert_string | ( | $ | table, | |
| $ | data | |||
| ) |
Generate an insert string
public
| string | the table upon which the query will be performed | |
| array | an associative array data of key/values |
| CI_DB_driver::is_write_type | ( | $ | sql | ) |
Determines if a query is a "write" type.
public
| string | An SQL query string |
| CI_DB_driver::last_query | ( | ) |
Returns the last query that was executed
public
| CI_DB_driver::list_fields | ( | $ | table = '' |
) |
Fetch MySQL Field Names
public
| string | the table name |
| CI_DB_driver::list_tables | ( | $ | constrain_by_prefix = FALSE |
) |
Returns an array of table names
public
| CI_DB_driver::load_rdriver | ( | ) |
Load the result drivers
public
| CI_DB_driver::platform | ( | ) |
The name of the platform in use (mysql, mssql, etc...)
public
| CI_DB_driver::primary | ( | $ | table = '' |
) |
Primary
Retrieves the primary key. It assumes that the row in the first position is the primary key
public
| string | the table name |
| CI_DB_driver::protect_identifiers | ( | $ | item, | |
| $ | prefix_single = FALSE | |||
| ) |
Protect Identifiers
This function adds backticks if appropriate based on db type
private
| mixed | the item to escape |
| CI_DB_driver::query | ( | $ | sql, | |
| $ | binds = FALSE, |
|||
| $ | return_object = TRUE | |||
| ) |
Execute the query
Accepts an SQL string as input and returns a result object upon successful execution of a "read" type query. Returns boolean TRUE upon successful execution of a "write" type query. Returns boolean FALSE upon failure, and if the $db_debug variable is set to TRUE will raise an error.
public
| string | An SQL query string | |
| array | An array of binding data |
| CI_DB_driver::simple_query | ( | $ | sql | ) |
| CI_DB_driver::table_exists | ( | $ | table_name | ) |
Determine if a particular table exists public
| CI_DB_driver::total_queries | ( | ) |
Returns the total number of queries
public
| CI_DB_driver::trans_complete | ( | ) |
Complete Transaction
public
| CI_DB_driver::trans_off | ( | ) |
Disable Transactions This permits transactions to be disabled at run-time.
public
| CI_DB_driver::trans_start | ( | $ | test_mode = FALSE |
) |
Start Transaction
public
| CI_DB_driver::trans_status | ( | ) |
Lets you retrieve the transaction flag to determine if it has failed
public
| CI_DB_driver::trans_strict | ( | $ | mode = TRUE |
) |
Enable/disable Transaction Strict Mode When strict mode is enabled, if you are running multiple groups of transactions, if one group fails all groups will be rolled back. If strict mode is disabled, each group is treated autonomously, meaning a failure of one group will not affect any others
public
| CI_DB_driver::update_string | ( | $ | table, | |
| $ | data, | |||
| $ | where | |||
| ) |
Generate an update string
public
| string | the table upon which the query will be performed | |
| array | an associative array data of key/values | |
| mixed | the "where" statement |
| CI_DB_driver::version | ( | ) |
Database Version Number. Returns a string containing the version of the database being used
public
| CI_DB_driver::$_protect_identifiers = TRUE |
| CI_DB_driver::$_reserved_identifiers = array('*') |
| CI_DB_driver::$_trans_depth = 0 |
| CI_DB_driver::$_trans_status = TRUE |
| CI_DB_driver::$autoinit = TRUE |
| CI_DB_driver::$benchmark = 0 |
| CI_DB_driver::$bind_marker = '?' |
| CI_DB_driver::$CACHE |
| CI_DB_driver::$cache_autodel = FALSE |
| CI_DB_driver::$cache_on = FALSE |
| CI_DB_driver::$cachedir = '' |
| CI_DB_driver::$char_set = 'utf8' |
| CI_DB_driver::$conn_id = FALSE |
| CI_DB_driver::$curs_id |
| CI_DB_driver::$data_cache = array() |
| CI_DB_driver::$database |
| CI_DB_driver::$db_debug = FALSE |
| CI_DB_driver::$dbcollat = 'utf8_general_ci' |
| CI_DB_driver::$dbdriver = 'mysql' |
| CI_DB_driver::$dbprefix = '' |
| CI_DB_driver::$hostname |
| CI_DB_driver::$limit_used |
| CI_DB_driver::$password |
| CI_DB_driver::$pconnect = FALSE |
| CI_DB_driver::$port = '' |
| CI_DB_driver::$queries = array() |
| CI_DB_driver::$query_count = 0 |
| CI_DB_driver::$query_times = array() |
| CI_DB_driver::$result_id = FALSE |
| CI_DB_driver::$save_queries = TRUE |
| CI_DB_driver::$stmt_id |
| CI_DB_driver::$swap_pre = '' |
| CI_DB_driver::$trans_enabled = TRUE |
| CI_DB_driver::$trans_strict = TRUE |
| CI_DB_driver::$username |
1.5.7.1