My Project
 All Data Structures Namespaces Functions Variables
Public Member Functions | Data Fields | Protected Member Functions
CI_DB_driver Class Reference
Inheritance diagram for CI_DB_driver:
CI_DB_active_record

Public Member Functions

 __construct ($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)
 
 escape_like_str ($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)
 

Data Fields

 $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
 

Protected Member Functions

 _reset_select ()
 

Constructor & Destructor Documentation

__construct (   $params)

Constructor. Accepts one parameter containing the database connection settings.

Parameters
array

Member Function Documentation

_cache_init ( )

Initialize the Cache Class

private

Returns
void
_has_operator (   $str)

Tests whether the string has an SQL operator

private

Parameters
string
Returns
bool
_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
_reset_select ( )
protected

Dummy method that allows Active Record class to be disabled

This function is used extensively by every db driver.

Returns
void
cache_delete (   $segment_one = '',
  $segment_two = '' 
)

Delete the cache files associated with a particular URI

public

Returns
void
cache_delete_all ( )

Delete All cache files

public

Returns
void
cache_off ( )

Disable Query Caching

public

Returns
void
cache_on ( )

Enable Query Caching

public

Returns
void
cache_set_path (   $path = '')

Set Cache Directory Path

public

Parameters
stringthe path to the cache directory
Returns
void
call_function (   $function)

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

public

Parameters
stringthe function name
mixedany parameters needed by the function
Returns
mixed
close ( )

Close DB Connection

public

Returns
void
compile_binds (   $sql,
  $binds 
)

Compile Bindings

public

Parameters
stringthe sql statement
arrayan array of bind data
Returns
string
db_set_charset (   $charset,
  $collation 
)

Set client character set

public

Parameters
string
string
Returns
resource
display_error (   $error = '',
  $swap = '',
  $native = FALSE 
)

Display an error message

public

Parameters
stringthe error message
stringany "swap" values
booleanwhether to localize the message
Returns
string sends the application/error_db.php template
elapsed_time (   $decimals = 6)

Calculate the aggregate query elapsed time

public

Parameters
integerThe number of decimal places
Returns
integer
escape (   $str)

"Smart" Escape String

Escapes data based on type Sets boolean and null types

public

Parameters
string
Returns
mixed
escape_like_str (   $str)

Escape LIKE String

Calls the individual driver for platform specific escaping for LIKE conditions

public

Parameters
string
Returns
mixed
field_data (   $table = '')

Returns an object with field data

public

Parameters
stringthe table name
Returns
object
field_exists (   $field_name,
  $table_name 
)

Determine if a particular field exists public

Parameters
string
string
Returns
boolean
initialize ( )

Initialize Database Settings

private Called by the constructor

Parameters
mixed
Returns
void
insert_string (   $table,
  $data 
)

Generate an insert string

public

Parameters
stringthe table upon which the query will be performed
arrayan associative array data of key/values
Returns
string
is_write_type (   $sql)

Determines if a query is a "write" type.

public

Parameters
stringAn SQL query string
Returns
boolean
last_query ( )

Returns the last query that was executed

public

Returns
void
list_fields (   $table = '')

Fetch MySQL Field Names

public

Parameters
stringthe table name
Returns
array
list_tables (   $constrain_by_prefix = FALSE)

Returns an array of table names

public

Returns
array
load_rdriver ( )

Load the result drivers

public

Returns
string the name of the result class
platform ( )

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

public

Returns
string
primary (   $table = '')

Primary

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

public

Parameters
stringthe table name
Returns
string
protect_identifiers (   $item,
  $prefix_single = FALSE 
)

Protect Identifiers

This function adds backticks if appropriate based on db type

private

Parameters
mixedthe item to escape
Returns
mixed the item with backticks
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
stringAn SQL query string
arrayAn array of binding data
Returns
mixed
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
stringthe sql query
Returns
mixed
table_exists (   $table_name)

Determine if a particular table exists public

Returns
boolean
total_queries ( )

Returns the total number of queries

public

Returns
integer
trans_complete ( )

Complete Transaction

public

Returns
bool
trans_off ( )

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

public

Returns
void
trans_start (   $test_mode = FALSE)

Start Transaction

public

Returns
void
trans_status ( )

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

public

Returns
bool
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
update_string (   $table,
  $data,
  $where 
)

Generate an update string

public

Parameters
stringthe table upon which the query will be performed
arrayan associative array data of key/values
mixedthe "where" statement
Returns
string
version ( )

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

public

Returns
string

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