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

Public Member Functions

 select ($select= '*', $escape=NULL)
 
 select_max ($select= '', $alias= '')
 
 select_min ($select= '', $alias= '')
 
 select_avg ($select= '', $alias= '')
 
 select_sum ($select= '', $alias= '')
 
 distinct ($val=TRUE)
 
 from ($from)
 
 join ($table, $cond, $type= '')
 
 where ($key, $value=NULL, $escape=TRUE)
 
 or_where ($key, $value=NULL, $escape=TRUE)
 
 where_in ($key=NULL, $values=NULL)
 
 or_where_in ($key=NULL, $values=NULL)
 
 where_not_in ($key=NULL, $values=NULL)
 
 or_where_not_in ($key=NULL, $values=NULL)
 
 like ($field, $match= '', $side= 'both')
 
 not_like ($field, $match= '', $side= 'both')
 
 or_like ($field, $match= '', $side= 'both')
 
 or_not_like ($field, $match= '', $side= 'both')
 
 group_by ($by)
 
 having ($key, $value= '', $escape=TRUE)
 
 or_having ($key, $value= '', $escape=TRUE)
 
 order_by ($orderby, $direction= '')
 
 limit ($value, $offset= '')
 
 offset ($offset)
 
 set ($key, $value= '', $escape=TRUE)
 
 get ($table= '', $limit=null, $offset=null)
 
 count_all_results ($table= '')
 
 get_where ($table= '', $where=null, $limit=null, $offset=null)
 
 insert_batch ($table= '', $set=NULL)
 
 set_insert_batch ($key, $value= '', $escape=TRUE)
 
 insert ($table= '', $set=NULL)
 
 replace ($table= '', $set=NULL)
 
 update ($table= '', $set=NULL, $where=NULL, $limit=NULL)
 
 update_batch ($table= '', $set=NULL, $index=NULL)
 
 set_update_batch ($key, $index= '', $escape=TRUE)
 
 empty_table ($table= '')
 
 truncate ($table= '')
 
 delete ($table= '', $where= '', $limit=NULL, $reset_data=TRUE)
 
 dbprefix ($table= '')
 
 set_dbprefix ($prefix= '')
 
 _object_to_array ($object)
 
 _object_to_array_batch ($object)
 
 start_cache ()
 
 stop_cache ()
 
 flush_cache ()
 
- Public Member Functions inherited from CI_DB_driver
 __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

 $ar_select = array()
 
 $ar_distinct = FALSE
 
 $ar_from = array()
 
 $ar_join = array()
 
 $ar_where = array()
 
 $ar_like = array()
 
 $ar_groupby = array()
 
 $ar_having = array()
 
 $ar_keys = array()
 
 $ar_limit = FALSE
 
 $ar_offset = FALSE
 
 $ar_order = FALSE
 
 $ar_orderby = array()
 
 $ar_set = array()
 
 $ar_wherein = array()
 
 $ar_aliased_tables = array()
 
 $ar_store_array = array()
 
 $ar_caching = FALSE
 
 $ar_cache_exists = array()
 
 $ar_cache_select = array()
 
 $ar_cache_from = array()
 
 $ar_cache_join = array()
 
 $ar_cache_where = array()
 
 $ar_cache_like = array()
 
 $ar_cache_groupby = array()
 
 $ar_cache_having = array()
 
 $ar_cache_orderby = array()
 
 $ar_cache_set = array()
 
 $ar_no_escape = array()
 
 $ar_cache_no_escape = array()
 
- Data Fields inherited from CI_DB_driver
 $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

 _max_min_avg_sum ($select= '', $alias= '', $type= 'MAX')
 
 _create_alias_from_table ($item)
 
 _where ($key, $value=NULL, $type= 'AND ', $escape=NULL)
 
 _where_in ($key=NULL, $values=NULL, $not=FALSE, $type= 'AND ')
 
 _like ($field, $match= '', $type= 'AND ', $side= 'both', $not= '')
 
 _having ($key, $value= '', $type= 'AND ', $escape=TRUE)
 
 _track_aliases ($table)
 
 _compile_select ($select_override=FALSE)
 
 _merge_cache ()
 
 _reset_run ($ar_reset_items)
 
 _reset_select ()
 
 _reset_write ()
 
- Protected Member Functions inherited from CI_DB_driver
 _reset_select ()
 

Member Function Documentation

_compile_select (   $select_override = FALSE)
protected

Compile the SELECT statement

Generates a query string based on which functions were used. Should not be called directly. The get() function calls it.

Returns
string
_create_alias_from_table (   $item)
protected

Determines the alias name based on the table

Parameters
string
Returns
string
_having (   $key,
  $value = '',
  $type = 'AND ',
  $escape = TRUE 
)
protected

Sets the HAVING values

Called by having() or or_having()

Parameters
string
string
Returns
object
_like (   $field,
  $match = '',
  $type = 'AND ',
  $side = 'both',
  $not = '' 
)
protected

Like

Called by like() or orlike()

Parameters
mixed
mixed
string
Returns
object
_max_min_avg_sum (   $select = '',
  $alias = '',
  $type = 'MAX' 
)
protected

Processing Function for the four functions above:

select_max() select_min() select_avg() select_sum()

Parameters
stringthe field
stringan alias
Returns
object
_merge_cache ( )
protected

Merge Cache

When called, this function merges any cached AR arrays with locally called ones.

Returns
void
_object_to_array (   $object)

Object to Array

Takes an object as input and converts the class variables to array key/vals

Parameters
object
Returns
array
_object_to_array_batch (   $object)

Object to Array

Takes an object as input and converts the class variables to array key/vals

Parameters
object
Returns
array
_reset_run (   $ar_reset_items)
protected

Resets the active record values. Called by the get() function

Parameters
arrayAn array of fields to reset
Returns
void
_reset_select ( )
protected

Resets the active record values. Called by the get() function

Returns
void
_reset_write ( )
protected

Resets the active record "write" values.

Called by the insert() update() insert_batch() update_batch() and delete() functions

Returns
void
_track_aliases (   $table)
protected

Track Aliases

Used to track SQL statements written with aliased tables.

Parameters
stringThe table to inspect
Returns
string
_where (   $key,
  $value = NULL,
  $type = 'AND ',
  $escape = NULL 
)
protected

Where

Called by where() or or_where()

Parameters
mixed
mixed
string
Returns
object
_where_in (   $key = NULL,
  $values = NULL,
  $not = FALSE,
  $type = 'AND ' 
)
protected

Where_in

Called by where_in, where_in_or, where_not_in, where_not_in_or

Parameters
stringThe field to search
arrayThe values searched on
booleanIf the statement would be IN or NOT IN
string
Returns
object
count_all_results (   $table = '')

"Count All Results" query

Generates a platform-specific query string that counts all records returned by an Active Record query.

Parameters
string
Returns
string
dbprefix (   $table = '')

DB Prefix

Prepends a database prefix if one exists in configuration

Parameters
stringthe table
Returns
string
delete (   $table = '',
  $where = '',
  $limit = NULL,
  $reset_data = TRUE 
)

Delete

Compiles a delete string and runs the query

Parameters
mixedthe table(s) to delete from. String or array
mixedthe where clause
mixedthe limit clause
boolean
Returns
object
distinct (   $val = TRUE)

DISTINCT

Sets a flag which tells the query string compiler to add DISTINCT

Parameters
bool
Returns
object
empty_table (   $table = '')

Empty Table

Compiles a delete string and runs "DELETE FROM table"

Parameters
stringthe table to empty
Returns
object
flush_cache ( )

Flush Cache

Empties the AR cache

public

Returns
void
from (   $from)

From

Generates the FROM portion of the query

Parameters
mixedcan be a string or array
Returns
object
get (   $table = '',
  $limit = null,
  $offset = null 
)

Get

Compiles the select statement based on the other functions called and runs the query

Parameters
stringthe table
stringthe limit clause
stringthe offset clause
Returns
object
get_where (   $table = '',
  $where = null,
  $limit = null,
  $offset = null 
)

Get_Where

Allows the where clause, limit and offset to be added directly

Parameters
stringthe where clause
stringthe limit clause
stringthe offset clause
Returns
object
group_by (   $by)

GROUP BY

Parameters
string
Returns
object
having (   $key,
  $value = '',
  $escape = TRUE 
)

Sets the HAVING value

Separates multiple calls with AND

Parameters
string
string
Returns
object
insert (   $table = '',
  $set = NULL 
)

Insert

Compiles an insert string and runs the query

Parameters
stringthe table to insert data into
arrayan associative array of insert values
Returns
object
insert_batch (   $table = '',
  $set = NULL 
)

Insert_Batch

Compiles batch insert strings and runs the queries

Parameters
stringthe table to retrieve the results from
arrayan associative array of insert values
Returns
object
join (   $table,
  $cond,
  $type = '' 
)

Join

Generates the JOIN portion of the query

Parameters
string
stringthe join condition
stringthe type of join
Returns
object
like (   $field,
  $match = '',
  $side = 'both' 
)

Like

Generates a LIKE% portion of the query. Separates multiple calls with AND

Parameters
mixed
mixed
Returns
object
limit (   $value,
  $offset = '' 
)

Sets the LIMIT value

Parameters
integerthe limit value
integerthe offset value
Returns
object
not_like (   $field,
  $match = '',
  $side = 'both' 
)

Not Like

Generates a NOT LIKE portion of the query. Separates multiple calls with AND

Parameters
mixed
mixed
Returns
object
offset (   $offset)

Sets the OFFSET value

Parameters
integerthe offset value
Returns
object
or_having (   $key,
  $value = '',
  $escape = TRUE 
)

Sets the OR HAVING value

Separates multiple calls with OR

Parameters
string
string
Returns
object
or_like (   $field,
  $match = '',
  $side = 'both' 
)

OR Like

Generates a LIKE% portion of the query. Separates multiple calls with OR

Parameters
mixed
mixed
Returns
object
or_not_like (   $field,
  $match = '',
  $side = 'both' 
)

OR Not Like

Generates a NOT LIKE portion of the query. Separates multiple calls with OR

Parameters
mixed
mixed
Returns
object
or_where (   $key,
  $value = NULL,
  $escape = TRUE 
)

OR Where

Generates the WHERE portion of the query. Separates multiple calls with OR

Parameters
mixed
mixed
Returns
object
or_where_in (   $key = NULL,
  $values = NULL 
)

Where_in_or

Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate

Parameters
stringThe field to search
arrayThe values searched on
Returns
object
or_where_not_in (   $key = NULL,
  $values = NULL 
)

Where_not_in_or

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with OR if appropriate

Parameters
stringThe field to search
arrayThe values searched on
Returns
object
order_by (   $orderby,
  $direction = '' 
)

Sets the ORDER BY value

Parameters
string
stringdirection: asc or desc
Returns
object
replace (   $table = '',
  $set = NULL 
)

Replace

Compiles an replace into string and runs the query

Parameters
stringthe table to replace data into
arrayan associative array of insert values
Returns
object
select (   $select = '*',
  $escape = NULL 
)

Select

Generates the SELECT portion of the query

Parameters
string
Returns
object
select_avg (   $select = '',
  $alias = '' 
)

Select Average

Generates a SELECT AVG(field) portion of a query

Parameters
stringthe field
stringan alias
Returns
object
select_max (   $select = '',
  $alias = '' 
)

Select Max

Generates a SELECT MAX(field) portion of a query

Parameters
stringthe field
stringan alias
Returns
object
select_min (   $select = '',
  $alias = '' 
)

Select Min

Generates a SELECT MIN(field) portion of a query

Parameters
stringthe field
stringan alias
Returns
object
select_sum (   $select = '',
  $alias = '' 
)

Select Sum

Generates a SELECT SUM(field) portion of a query

Parameters
stringthe field
stringan alias
Returns
object
set (   $key,
  $value = '',
  $escape = TRUE 
)

The "set" function. Allows key/value pairs to be set for inserting or updating

Parameters
mixed
string
boolean
Returns
object
set_dbprefix (   $prefix = '')

Set DB Prefix

Set's the DB Prefix to something new without needing to reconnect

Parameters
stringthe prefix
Returns
string
set_insert_batch (   $key,
  $value = '',
  $escape = TRUE 
)

The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts

Parameters
mixed
string
boolean
Returns
object
set_update_batch (   $key,
  $index = '',
  $escape = TRUE 
)

The "set_update_batch" function. Allows key/value pairs to be set for batch updating

Parameters
array
string
boolean
Returns
object
start_cache ( )

Start Cache

Starts AR caching

Returns
void
stop_cache ( )

Stop Cache

Stops AR caching

Returns
void
truncate (   $table = '')

Truncate

Compiles a truncate string and runs the query If the database does not support the truncate() command This function maps to "DELETE FROM table"

Parameters
stringthe table to truncate
Returns
object
update (   $table = '',
  $set = NULL,
  $where = NULL,
  $limit = NULL 
)

Update

Compiles an update string and runs the query

Parameters
stringthe table to retrieve the results from
arrayan associative array of update values
mixedthe where clause
Returns
object
update_batch (   $table = '',
  $set = NULL,
  $index = NULL 
)

Update_Batch

Compiles an update string and runs the query

Parameters
stringthe table to retrieve the results from
arrayan associative array of update values
stringthe where key
Returns
object
where (   $key,
  $value = NULL,
  $escape = TRUE 
)

Where

Generates the WHERE portion of the query. Separates multiple calls with AND

Parameters
mixed
mixed
Returns
object
where_in (   $key = NULL,
  $values = NULL 
)

Where_in

Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

Parameters
stringThe field to search
arrayThe values searched on
Returns
object
where_not_in (   $key = NULL,
  $values = NULL 
)

Where_not_in

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with AND if appropriate

Parameters
stringThe field to search
arrayThe values searched on
Returns
object

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