Properties

$username

$username : 

Type

$password

$password : 

Type

$hostname

$hostname : 

Type

$database

$database : 

Type

$dbdriver

$dbdriver : 

Type

$dbprefix

$dbprefix : 

Type

$char_set

$char_set : 

Type

$dbcollat

$dbcollat : 

Type

$autoinit

$autoinit : 

Type

$swap_pre

$swap_pre : 

Type

$port

$port : 

Type

$pconnect

$pconnect : 

Type

$conn_id

$conn_id : 

Type

$result_id

$result_id : 

Type

$db_debug

$db_debug : 

Type

$benchmark

$benchmark : 

Type

$query_count

$query_count : 

Type

$bind_marker

$bind_marker : 

Type

$save_queries

$save_queries : 

Type

$queries

$queries : 

Type

$query_times

$query_times : 

Type

$data_cache

$data_cache : 

Type

$trans_enabled

$trans_enabled : 

Type

$trans_strict

$trans_strict : 

Type

$_trans_depth

$_trans_depth : 

Type

$_trans_status

$_trans_status : 

Type

$cache_on

$cache_on : 

Type

$cachedir

$cachedir : 

Type

$cache_autodel

$cache_autodel : 

Type

$CACHE

$CACHE : 

Type

$_protect_identifiers

$_protect_identifiers : 

Type

$_reserved_identifiers

$_reserved_identifiers : 

Type

$stmt_id

$stmt_id : 

Type

$curs_id

$curs_id : 

Type

$limit_used

$limit_used : 

Type

Methods

__construct()

__construct(  $params) 

Constructor. Accepts one parameter containing the database connection settings.

Parameters

$params

initialize()

initialize() : void

Initialize Database Settings

db_set_charset()

db_set_charset(  $charset,   $collation) : resource

Set client character set

Parameters

$charset
$collation

Returns

resource

platform()

platform() : string

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

..)

Returns

string

version()

version() : string

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

Returns

string

query()

query(  $sql,   $binds = FALSE,   $return_object = TRUE) : mixed

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.

Parameters

$sql
$binds
$return_object

Returns

mixed

load_rdriver()

load_rdriver() : string

Load the result drivers

Returns

string —

the name of the result class

simple_query()

simple_query(  $sql) : mixed

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.

Parameters

$sql

Returns

mixed

trans_off()

trans_off() : void

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

trans_strict()

trans_strict(  $mode = TRUE) : void

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

Parameters

$mode

trans_start()

trans_start(  $test_mode = FALSE) : void

Start Transaction

Parameters

$test_mode

trans_complete()

trans_complete() : boolean

Complete Transaction

Returns

boolean

trans_status()

trans_status() : boolean

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

Returns

boolean

compile_binds()

compile_binds(  $sql,   $binds) : string

Compile Bindings

Parameters

$sql
$binds

Returns

string

is_write_type()

is_write_type(  $sql) : boolean

Determines if a query is a "write" type.

Parameters

$sql

Returns

boolean

elapsed_time()

elapsed_time(  $decimals = 6) : integer

Calculate the aggregate query elapsed time

Parameters

$decimals

Returns

integer

total_queries()

total_queries() : integer

Returns the total number of queries

Returns

integer

last_query()

last_query() : void

Returns the last query that was executed

escape()

escape(  $str) : mixed

"Smart" Escape String

Escapes data based on type Sets boolean and null types

Parameters

$str

Returns

mixed

escape_like_str()

escape_like_str(  $str) : mixed

Escape LIKE String

Calls the individual driver for platform specific escaping for LIKE conditions

Parameters

$str

Returns

mixed

primary()

primary(  $table = '') : string

Primary

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

Parameters

$table

Returns

string

list_tables()

list_tables(  $constrain_by_prefix = FALSE) : array

Returns an array of table names

Parameters

$constrain_by_prefix

Returns

array

table_exists()

table_exists(  $table_name) : boolean

Determine if a particular table exists

Parameters

$table_name

Returns

boolean

list_fields()

list_fields(  $table = '') : array

Fetch MySQL Field Names

Parameters

$table

Returns

array

field_exists()

field_exists(  $field_name,   $table_name) : boolean

Determine if a particular field exists

Parameters

$field_name
$table_name

Returns

boolean

field_data()

field_data(  $table = '') : object

Returns an object with field data

Parameters

$table

Returns

object

insert_string()

insert_string(  $table,   $data) : string

Generate an insert string

Parameters

$table
$data

Returns

string

update_string()

update_string(  $table,   $data,   $where) : string

Generate an update string

Parameters

$table
$data
$where

Returns

string

_has_operator()

_has_operator(  $str) : boolean

Tests whether the string has an SQL operator

Parameters

$str

Returns

boolean

call_function()

call_function(  $function) : mixed

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

Parameters

$function

Returns

mixed

cache_set_path()

cache_set_path(  $path = '') : void

Set Cache Directory Path

Parameters

$path

cache_on()

cache_on() : void

Enable Query Caching

cache_off()

cache_off() : void

Disable Query Caching

cache_delete()

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

Delete the cache files associated with a particular URI

Parameters

$segment_one
$segment_two

cache_delete_all()

cache_delete_all() : void

Delete All cache files

_cache_init()

_cache_init() : void

Initialize the Cache Class

close()

close() : void

Close DB Connection

display_error()

display_error(  $error = '',   $swap = '',   $native = FALSE) : string

Display an error message

Parameters

$error
$swap
$native

Returns

string —

sends the application/error_db.php template

protect_identifiers()

protect_identifiers(  $item,   $prefix_single = FALSE) : mixed

Protect Identifiers

This function adds backticks if appropriate based on db type

Parameters

$item
$prefix_single

Returns

mixed —

the item with backticks

_protect_identifiers()

_protect_identifiers(  $item,   $prefix_single = FALSE,   $protect_identifiers = NULL,   $field_exists = TRUE) : string

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.

Parameters

$item
$prefix_single
$protect_identifiers
$field_exists

Returns

string

_reset_select()

_reset_select() : void

Dummy method that allows Active Record class to be disabled

This function is used extensively by every db driver.