CI_DB_driver Class Reference

Inherited by CI_DB_active_record.

List of all members.

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


Member Function Documentation

CI_DB_driver::_cache_init (  ) 

Initialize the Cache Class

private

Returns:
void

CI_DB_driver::_has_operator ( str  ) 

Tests whether the string has an SQL operator

private

Parameters:
string 
Returns:
bool

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

Parameters:
string 
bool 
mixed 
bool 
Returns:
string

CI_DB_driver::cache_delete ( segment_one = '',
segment_two = '' 
)

Delete the cache files associated with a particular URI

public

Returns:
void

CI_DB_driver::cache_delete_all (  ) 

Delete All cache files

public

Returns:
void

CI_DB_driver::cache_off (  ) 

Disable Query Caching

public

Returns:
void

CI_DB_driver::cache_on (  ) 

Enable Query Caching

public

Returns:
void

CI_DB_driver::cache_set_path ( path = ''  ) 

Set Cache Directory Path

public

Parameters:
string the path to the cache directory
Returns:
void

CI_DB_driver::call_function ( function  ) 

Enables a native PHP function to be run, using a platform agnostic wrapper.

public

Parameters:
string the function name
mixed any parameters needed by the function
Returns:
mixed

CI_DB_driver::CI_DB_driver ( params  ) 

Constructor. Accepts one parameter containing the database connection settings.

Parameters:
array 

CI_DB_driver::close (  ) 

Close DB Connection

public

Returns:
void

CI_DB_driver::compile_binds ( sql,
binds 
)

Compile Bindings

public

Parameters:
string the sql statement
array an array of bind data
Returns:
string

CI_DB_driver::db_set_charset ( charset,
collation 
)

Set client character set

public

Parameters:
string 
string 
Returns:
resource

CI_DB_driver::display_error ( error = '',
swap = '',
native = FALSE 
)

Display an error message

public

Parameters:
string the error message
string any "swap" values
boolean whether to localize the message
Returns:
string sends the application/error_db.php template

CI_DB_driver::elapsed_time ( decimals = 6  ) 

Calculate the aggregate query elapsed time

public

Parameters:
integer The number of decimal places
Returns:
integer

CI_DB_driver::escape ( str  ) 

"Smart" Escape String

Escapes data based on type Sets boolean and null types

public

Parameters:
string 
Returns:
integer

CI_DB_driver::field_data ( table = ''  ) 

Returns an object with field data

public

Parameters:
string the table name
Returns:
object

CI_DB_driver::field_exists ( field_name,
table_name 
)

Determine if a particular field exists public

Parameters:
string 
string 
Returns:
boolean

CI_DB_driver::initialize (  ) 

Initialize Database Settings

private Called by the constructor

Parameters:
mixed 
Returns:
void

CI_DB_driver::insert_string ( table,
data 
)

Generate an insert string

public

Parameters:
string the table upon which the query will be performed
array an associative array data of key/values
Returns:
string

CI_DB_driver::is_write_type ( sql  ) 

Determines if a query is a "write" type.

public

Parameters:
string An SQL query string
Returns:
boolean

CI_DB_driver::last_query (  ) 

Returns the last query that was executed

public

Returns:
void

CI_DB_driver::list_fields ( table = ''  ) 

Fetch MySQL Field Names

public

Parameters:
string the table name
Returns:
array

CI_DB_driver::list_tables ( constrain_by_prefix = FALSE  ) 

Returns an array of table names

public

Returns:
array

CI_DB_driver::load_rdriver (  ) 

Load the result drivers

public

Returns:
string the name of the result class

CI_DB_driver::platform (  ) 

The name of the platform in use (mysql, mssql, etc...)

public

Returns:
string

CI_DB_driver::primary ( table = ''  ) 

Primary

Retrieves the primary key. It assumes that the row in the first position is the primary key

public

Parameters:
string the table name
Returns:
string

CI_DB_driver::protect_identifiers ( item,
prefix_single = FALSE 
)

Protect Identifiers

This function adds backticks if appropriate based on db type

private

Parameters:
mixed the item to escape
Returns:
mixed the item with backticks

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

Parameters:
string An SQL query string
array An array of binding data
Returns:
mixed

CI_DB_driver::simple_query ( sql  ) 

Simple Query This is a simplified version of the query() function. Internally we only use it when running transaction commands since they do not require all the features of the main query() function.

public

Parameters:
string the sql query
Returns:
mixed

CI_DB_driver::table_exists ( table_name  ) 

Determine if a particular table exists public

Returns:
boolean

CI_DB_driver::total_queries (  ) 

Returns the total number of queries

public

Returns:
integer

CI_DB_driver::trans_complete (  ) 

Complete Transaction

public

Returns:
bool

CI_DB_driver::trans_off (  ) 

Disable Transactions This permits transactions to be disabled at run-time.

public

Returns:
void

CI_DB_driver::trans_start ( test_mode = FALSE  ) 

Start Transaction

public

Returns:
void

CI_DB_driver::trans_status (  ) 

Lets you retrieve the transaction flag to determine if it has failed

public

Returns:
bool

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

Returns:
void

CI_DB_driver::update_string ( table,
data,
where 
)

Generate an update string

public

Parameters:
string the table upon which the query will be performed
array an associative array data of key/values
mixed the "where" statement
Returns:
string

CI_DB_driver::version (  ) 

Database Version Number. Returns a string containing the version of the database being used

public

Returns:
string


Member Data Documentation

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


The documentation for this class was generated from the following file:

Generated on Sun Nov 16 16:09:08 2008 for CodeIgniter by  doxygen 1.5.7.1