Public Member Functions | |
select ($select= '*', $escape=NULL) | |
select_max ($select= '', $alias= '') | |
select_min ($select= '', $alias= '') | |
select_avg ($select= '', $alias= '') | |
select_sum ($select= '', $alias= '') | |
_max_min_avg_sum ($select= '', $alias= '', $type= 'MAX') | |
_create_alias_from_table ($item) | |
distinct ($val=TRUE) | |
from ($from) | |
join ($table, $cond, $type= '') | |
where ($key, $value=NULL, $escape=TRUE) | |
or_where ($key, $value=NULL, $escape=TRUE) | |
orwhere ($key, $value=NULL, $escape=TRUE) | |
_where ($key, $value=NULL, $type= 'AND ', $escape=NULL) | |
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) | |
_where_in ($key=NULL, $values=NULL, $not=FALSE, $type= 'AND ') | |
like ($field, $match= '', $side= 'both') | |
not_like ($field, $match= '', $side= 'both') | |
or_like ($field, $match= '', $side= 'both') | |
or_not_like ($field, $match= '', $side= 'both') | |
orlike ($field, $match= '', $side= 'both') | |
_like ($field, $match= '', $type= 'AND ', $side= 'both', $not= '') | |
group_by ($by) | |
groupby ($by) | |
having ($key, $value= '', $escape=TRUE) | |
orhaving ($key, $value= '', $escape=TRUE) | |
or_having ($key, $value= '', $escape=TRUE) | |
_having ($key, $value= '', $type= 'AND ', $escape=TRUE) | |
order_by ($orderby, $direction= '') | |
orderby ($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) | |
getwhere ($table= '', $where=null, $limit=null, $offset=null) | |
insert ($table= '', $set=NULL) | |
update ($table= '', $set=NULL, $where=NULL, $limit=NULL) | |
empty_table ($table= '') | |
truncate ($table= '') | |
delete ($table= '', $where= '', $limit=NULL, $reset_data=TRUE) | |
dbprefix ($table= '') | |
_track_aliases ($table) | |
_compile_select ($select_override=FALSE) | |
_object_to_array ($object) | |
start_cache () | |
stop_cache () | |
flush_cache () | |
_merge_cache () | |
_reset_run ($ar_reset_items) | |
_reset_select () | |
_reset_write () | |
Public Attributes | |
$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_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() |
CI_DB_active_record::_compile_select | ( | $ | select_override = FALSE |
) |
Compile the SELECT statement
Generates a query string based on which functions were used. Should not be called directly. The get() function calls it.
private
CI_DB_active_record::_create_alias_from_table | ( | $ | item | ) |
Determines the alias name based on the table
private
string |
CI_DB_active_record::_having | ( | $ | key, | |
$ | value = '' , |
|||
$ | type = 'AND ' , |
|||
$ | escape = TRUE | |||
) |
Sets the HAVING values
Called by having() or or_having()
private
string | ||
string |
CI_DB_active_record::_like | ( | $ | field, | |
$ | match = '' , |
|||
$ | type = 'AND ' , |
|||
$ | side = 'both' , |
|||
$ | not = '' | |||
) |
CI_DB_active_record::_max_min_avg_sum | ( | $ | select = '' , |
|
$ | alias = '' , |
|||
$ | type = 'MAX' | |||
) |
Processing Function for the four functions above:
select_max() select_min() select_avg() select_sum()
public
string | the field | |
string | an alias |
CI_DB_active_record::_merge_cache | ( | ) |
Merge Cache
When called, this function merges any cached AR arrays with locally called ones.
private
CI_DB_active_record::_object_to_array | ( | $ | object | ) |
Object to Array
Takes an object as input and converts the class variables to array key/vals
public
object |
CI_DB_active_record::_reset_run | ( | $ | ar_reset_items | ) |
Resets the active record values. Called by the get() function
private
array | An array of fields to reset |
CI_DB_active_record::_reset_select | ( | ) |
CI_DB_active_record::_reset_write | ( | ) |
CI_DB_active_record::_track_aliases | ( | $ | table | ) |
Track Aliases
Used to track SQL statements written with aliased tables.
private
string | The table to inspect |
CI_DB_active_record::_where | ( | $ | key, | |
$ | value = NULL , |
|||
$ | type = 'AND ' , |
|||
$ | escape = NULL | |||
) |
CI_DB_active_record::_where_in | ( | $ | key = NULL , |
|
$ | values = NULL , |
|||
$ | not = FALSE , |
|||
$ | type = 'AND ' | |||
) |
Where_in
Called by where_in, where_in_or, where_not_in, where_not_in_or
public
string | The field to search | |
array | The values searched on | |
boolean | If the statement would be IN or NOT IN | |
string |
CI_DB_active_record::count_all_results | ( | $ | table = '' |
) |
"Count All Results" query
Generates a platform-specific query string that counts all records returned by an Active Record query.
public
string |
CI_DB_active_record::dbprefix | ( | $ | table = '' |
) |
DB Prefix
Prepends a database prefix if one exists in configuration
public
string | the table |
CI_DB_active_record::delete | ( | $ | table = '' , |
|
$ | where = '' , |
|||
$ | limit = NULL , |
|||
$ | reset_data = TRUE | |||
) |
Delete
Compiles a delete string and runs the query
public
mixed | the table(s) to delete from. String or array | |
mixed | the where clause | |
mixed | the limit clause | |
boolean |
CI_DB_active_record::distinct | ( | $ | val = TRUE |
) |
DISTINCT
Sets a flag which tells the query string compiler to add DISTINCT
public
bool |
CI_DB_active_record::empty_table | ( | $ | table = '' |
) |
Empty Table
Compiles a delete string and runs "DELETE FROM table"
public
string | the table to empty |
CI_DB_active_record::flush_cache | ( | ) |
Flush Cache
Empties the AR cache
public
CI_DB_active_record::from | ( | $ | from | ) |
From
Generates the FROM portion of the query
public
mixed | can be a string or array |
CI_DB_active_record::get | ( | $ | table = '' , |
|
$ | limit = null , |
|||
$ | offset = null | |||
) |
Get
Compiles the select statement based on the other functions called and runs the query
public
string | the table | |
string | the limit clause | |
string | the offset clause |
CI_DB_active_record::get_where | ( | $ | table = '' , |
|
$ | where = null , |
|||
$ | limit = null , |
|||
$ | offset = null | |||
) |
Get_Where
Allows the where clause, limit and offset to be added directly
public
string | the where clause | |
string | the limit clause | |
string | the offset clause |
CI_DB_active_record::getwhere | ( | $ | table = '' , |
|
$ | where = null , |
|||
$ | limit = null , |
|||
$ | offset = null | |||
) |
getwhere() is an alias of get_where() this function is here for backwards compatibility, as getwhere() has been deprecated
CI_DB_active_record::group_by | ( | $ | by | ) |
GROUP BY
public
string |
CI_DB_active_record::groupby | ( | $ | by | ) |
groupby() is an alias of group_by() this function is here for backwards compatibility, as groupby() has been deprecated
CI_DB_active_record::having | ( | $ | key, | |
$ | value = '' , |
|||
$ | escape = TRUE | |||
) |
Sets the HAVING value
Separates multiple calls with AND
public
string | ||
string |
CI_DB_active_record::insert | ( | $ | table = '' , |
|
$ | set = NULL | |||
) |
Insert
Compiles an insert string and runs the query
public
string | the table to retrieve the results from | |
array | an associative array of insert values |
CI_DB_active_record::join | ( | $ | table, | |
$ | cond, | |||
$ | type = '' | |||
) |
Join
Generates the JOIN portion of the query
public
string | ||
string | the join condition | |
string | the type of join |
CI_DB_active_record::like | ( | $ | field, | |
$ | match = '' , |
|||
$ | side = 'both' | |||
) |
Like
Generates a LIKE% portion of the query. Separates multiple calls with AND
public
mixed | ||
mixed |
CI_DB_active_record::limit | ( | $ | value, | |
$ | offset = '' | |||
) |
Sets the LIMIT value
public
integer | the limit value | |
integer | the offset value |
CI_DB_active_record::not_like | ( | $ | field, | |
$ | match = '' , |
|||
$ | side = 'both' | |||
) |
Not Like
Generates a NOT LIKE portion of the query. Separates multiple calls with AND
public
mixed | ||
mixed |
CI_DB_active_record::offset | ( | $ | offset | ) |
Sets the OFFSET value
public
integer | the offset value |
CI_DB_active_record::or_having | ( | $ | key, | |
$ | value = '' , |
|||
$ | escape = TRUE | |||
) |
Sets the OR HAVING value
Separates multiple calls with OR
public
string | ||
string |
CI_DB_active_record::or_like | ( | $ | field, | |
$ | match = '' , |
|||
$ | side = 'both' | |||
) |
OR Like
Generates a LIKE% portion of the query. Separates multiple calls with OR
public
mixed | ||
mixed |
CI_DB_active_record::or_not_like | ( | $ | field, | |
$ | match = '' , |
|||
$ | side = 'both' | |||
) |
OR Not Like
Generates a NOT LIKE portion of the query. Separates multiple calls with OR
public
mixed | ||
mixed |
CI_DB_active_record::or_where | ( | $ | key, | |
$ | value = NULL , |
|||
$ | escape = TRUE | |||
) |
OR Where
Generates the WHERE portion of the query. Separates multiple calls with OR
public
mixed | ||
mixed |
CI_DB_active_record::or_where_in | ( | $ | key = NULL , |
|
$ | values = NULL | |||
) |
Where_in_or
Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate
public
string | The field to search | |
array | The values searched on |
CI_DB_active_record::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
public
string | The field to search | |
array | The values searched on |
CI_DB_active_record::order_by | ( | $ | orderby, | |
$ | direction = '' | |||
) |
Sets the ORDER BY value
public
string | ||
string | direction: asc or desc |
CI_DB_active_record::orderby | ( | $ | orderby, | |
$ | direction = '' | |||
) |
orderby() is an alias of order_by() this function is here for backwards compatibility, as orderby() has been deprecated
CI_DB_active_record::orhaving | ( | $ | key, | |
$ | value = '' , |
|||
$ | escape = TRUE | |||
) |
orhaving() is an alias of or_having() this function is here for backwards compatibility, as orhaving() has been deprecated
CI_DB_active_record::orlike | ( | $ | field, | |
$ | match = '' , |
|||
$ | side = 'both' | |||
) |
CI_DB_active_record::orwhere | ( | $ | key, | |
$ | value = NULL , |
|||
$ | escape = TRUE | |||
) |
orwhere() is an alias of or_where() this function is here for backwards compatibility, as orwhere() has been deprecated
CI_DB_active_record::select | ( | $ | select = '*' , |
|
$ | escape = NULL | |||
) |
Select
Generates the SELECT portion of the query
public
string |
CI_DB_active_record::select_avg | ( | $ | select = '' , |
|
$ | alias = '' | |||
) |
Select Average
Generates a SELECT AVG(field) portion of a query
public
string | the field | |
string | an alias |
CI_DB_active_record::select_max | ( | $ | select = '' , |
|
$ | alias = '' | |||
) |
Select Max
Generates a SELECT MAX(field) portion of a query
public
string | the field | |
string | an alias |
CI_DB_active_record::select_min | ( | $ | select = '' , |
|
$ | alias = '' | |||
) |
Select Min
Generates a SELECT MIN(field) portion of a query
public
string | the field | |
string | an alias |
CI_DB_active_record::select_sum | ( | $ | select = '' , |
|
$ | alias = '' | |||
) |
Select Sum
Generates a SELECT SUM(field) portion of a query
public
string | the field | |
string | an alias |
CI_DB_active_record::set | ( | $ | key, | |
$ | value = '' , |
|||
$ | escape = TRUE | |||
) |
The "set" function. Allows key/value pairs to be set for inserting or updating
public
mixed | ||
string | ||
boolean |
CI_DB_active_record::start_cache | ( | ) |
Start Cache
Starts AR caching
public
CI_DB_active_record::stop_cache | ( | ) |
Stop Cache
Stops AR caching
public
CI_DB_active_record::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"
public
string | the table to truncate |
CI_DB_active_record::update | ( | $ | table = '' , |
|
$ | set = NULL , |
|||
$ | where = NULL , |
|||
$ | limit = NULL | |||
) |
Update
Compiles an update string and runs the query
public
string | the table to retrieve the results from | |
array | an associative array of update values | |
mixed | the where clause |
CI_DB_active_record::where | ( | $ | key, | |
$ | value = NULL , |
|||
$ | escape = TRUE | |||
) |
Where
Generates the WHERE portion of the query. Separates multiple calls with AND
public
mixed | ||
mixed |
CI_DB_active_record::where_in | ( | $ | key = NULL , |
|
$ | values = NULL | |||
) |
Where_in
Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate
public
string | The field to search | |
array | The values searched on |
CI_DB_active_record::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
public
string | The field to search | |
array | The values searched on |
CI_DB_active_record::$ar_aliased_tables = array() |
CI_DB_active_record::$ar_cache_exists = array() |
CI_DB_active_record::$ar_cache_from = array() |
CI_DB_active_record::$ar_cache_groupby = array() |
CI_DB_active_record::$ar_cache_having = array() |
CI_DB_active_record::$ar_cache_join = array() |
CI_DB_active_record::$ar_cache_like = array() |
CI_DB_active_record::$ar_cache_orderby = array() |
CI_DB_active_record::$ar_cache_select = array() |
CI_DB_active_record::$ar_cache_set = array() |
CI_DB_active_record::$ar_cache_where = array() |
CI_DB_active_record::$ar_caching = FALSE |
CI_DB_active_record::$ar_distinct = FALSE |
CI_DB_active_record::$ar_from = array() |
CI_DB_active_record::$ar_groupby = array() |
CI_DB_active_record::$ar_having = array() |
CI_DB_active_record::$ar_join = array() |
CI_DB_active_record::$ar_like = array() |
CI_DB_active_record::$ar_limit = FALSE |
CI_DB_active_record::$ar_offset = FALSE |
CI_DB_active_record::$ar_order = FALSE |
CI_DB_active_record::$ar_orderby = array() |
CI_DB_active_record::$ar_select = array() |
CI_DB_active_record::$ar_set = array() |
CI_DB_active_record::$ar_store_array = array() |
CI_DB_active_record::$ar_where = array() |
CI_DB_active_record::$ar_wherein = array() |