PHP Class CI_DB_active_record, 68kb

This is the platform-independent base Active Record implementation class.
Author: ExpressionEngine Dev Team
Inheritance: extends CI_DB_driver
Afficher le fichier Open project: 68kb/68kb Class Usage Examples

Méthodes publiques

Свойство Type Description
$ar_aliased_tables
$ar_cache_exists
$ar_cache_from
$ar_cache_groupby
$ar_cache_having
$ar_cache_join
$ar_cache_like
$ar_cache_orderby
$ar_cache_select
$ar_cache_set
$ar_cache_where
$ar_caching Active Record Caching variables
$ar_distinct
$ar_from
$ar_groupby
$ar_having
$ar_join
$ar_like
$ar_limit
$ar_offset
$ar_order
$ar_orderby
$ar_select
$ar_set
$ar_store_array
$ar_where
$ar_wherein

Méthodes publiques

Méthode Description
_compile_select ( $select_override = FALSE ) : string Compile the SELECT statement
_create_alias_from_table ( $item ) : string Determines the alias name based on the table
_having ( $key, $value = '', $type = 'AND ', $escape = TRUE ) : object Sets the HAVING values
_like ( $field, $match = '', $type = 'AND ', $side = 'both', $not = '' ) : object Like
_max_min_avg_sum ( $select = '', $alias = '', $type = 'MAX' ) : object Processing Function for the four functions above:
_merge_cache ( ) : void Merge Cache
_object_to_array ( $object ) : array Object to Array
_object_to_array_batch ( $object ) : array Object to Array
_reset_run ( $ar_reset_items ) : void Resets the active record values. Called by the get() function
_reset_select ( ) : void Resets the active record values. Called by the get() function
_reset_write ( ) : void Resets the active record "write" values.
_track_aliases ( $table ) : string Track Aliases
_where ( $key, $value = NULL, $type = 'AND ', $escape = NULL ) : object Where
_where_in ( $key = NULL, $values = NULL, $not = FALSE, $type = 'AND ' ) : object Where_in
count_all_results ( $table = '' ) : string "Count All Results" query
dbprefix ( $table = '' ) : string DB Prefix
delete ( $table = '', $where = '', $limit = NULL, $reset_data = TRUE ) : object Delete
distinct ( $val = TRUE ) : object DISTINCT
empty_table ( $table = '' ) : object Empty Table
flush_cache ( ) : void Flush Cache
from ( $from ) : object From
get ( $table = '', $limit = null, $offset = null ) : object Get
get_where ( $table = '', $where = null, $limit = null, $offset = null ) : object Get_Where
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
group_by ( $by ) : object GROUP BY
groupby ( $by ) groupby() is an alias of group_by() this function is here for backwards compatibility, as groupby() has been deprecated
having ( $key, $value = '', $escape = TRUE ) : object Sets the HAVING value
insert ( $table = '', $set = NULL ) : object Insert
insert_batch ( $table = '', $set = NULL ) : object Insert_Batch
join ( $table, $cond, $type = '' ) : object Join
like ( $field, $match = '', $side = 'both' ) : object Like
limit ( $value, $offset = '' ) : object Sets the LIMIT value
not_like ( $field, $match = '', $side = 'both' ) : object Not Like
offset ( $offset ) : object Sets the OFFSET value
or_having ( $key, $value = '', $escape = TRUE ) : object Sets the OR HAVING value
or_like ( $field, $match = '', $side = 'both' ) : object OR Like
or_not_like ( $field, $match = '', $side = 'both' ) : object OR Not Like
or_where ( $key, $value = NULL, $escape = TRUE ) : object OR Where
or_where_in ( $key = NULL, $values = NULL ) : object Where_in_or
or_where_not_in ( $key = NULL, $values = NULL ) : object Where_not_in_or
order_by ( $orderby, $direction = '' ) : object Sets the ORDER BY value
orderby ( $orderby, $direction = '' ) orderby() is an alias of order_by() this function is here for backwards compatibility, as orderby() has been deprecated
orhaving ( $key, $value = '', $escape = TRUE ) orhaving() is an alias of or_having() this function is here for backwards compatibility, as orhaving() has been deprecated
orlike ( $field, $match = '', $side = 'both' ) orlike() is an alias of or_like() this function is here for backwards compatibility, as orlike() has been deprecated
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
replace ( $table = '', $set = NULL )
select ( $select = '*', $escape = NULL ) : object Select
select_avg ( $select = '', $alias = '' ) : object Select Average
select_max ( $select = '', $alias = '' ) : object Select Max
select_min ( $select = '', $alias = '' ) : object Select Min
select_sum ( $select = '', $alias = '' ) : object Select Sum
set ( $key, $value = '', $escape = TRUE ) : object The "set" function. Allows key/value pairs to be set for inserting or updating
set_insert_batch ( $key, $value = '', $escape = TRUE ) : object The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts
set_update_batch ( $key, $index = '', $escape = TRUE ) : object The "set_update_batch" function. Allows key/value pairs to be set for batch updating
start_cache ( ) : void Start Cache
stop_cache ( ) : void Stop Cache
truncate ( $table = '' ) : object Truncate
update ( $table = '', $set = NULL, $where = NULL, $limit = NULL ) : object Update
update_batch ( $table = '', $set = NULL, $index = NULL ) : object Update_Batch
where ( $key, $value = NULL, $escape = TRUE ) : object Where
where_in ( $key = NULL, $values = NULL ) : object Where_in
where_not_in ( $key = NULL, $values = NULL ) : object Where_not_in

Method Details

_compile_select() public méthode

Generates a query string based on which functions were used. Should not be called directly. The get() function calls it.
public _compile_select ( $select_override = FALSE ) : string
Résultat string

_create_alias_from_table() public méthode

Determines the alias name based on the table
public _create_alias_from_table ( $item ) : string
Résultat string

_having() public méthode

Called by having() or or_having()
public _having ( $key, $value = '', $type = 'AND ', $escape = TRUE ) : object
Résultat object

_like() public méthode

Called by like() or orlike()
public _like ( $field, $match = '', $type = 'AND ', $side = 'both', $not = '' ) : object
Résultat object

_max_min_avg_sum() public méthode

select_max() select_min() select_avg() select_sum()
public _max_min_avg_sum ( $select = '', $alias = '', $type = 'MAX' ) : object
Résultat object

_merge_cache() public méthode

When called, this function merges any cached AR arrays with locally called ones.
public _merge_cache ( ) : void
Résultat void

_object_to_array() public méthode

Takes an object as input and converts the class variables to array key/vals
public _object_to_array ( $object ) : array
Résultat array

_object_to_array_batch() public méthode

Takes an object as input and converts the class variables to array key/vals
public _object_to_array_batch ( $object ) : array
Résultat array

_reset_run() public méthode

Resets the active record values. Called by the get() function
public _reset_run ( $ar_reset_items ) : void
Résultat void

_reset_select() public méthode

Resets the active record values. Called by the get() function
public _reset_select ( ) : void
Résultat void

_reset_write() public méthode

Called by the insert() update() and delete() functions
public _reset_write ( ) : void
Résultat void

_track_aliases() public méthode

Used to track SQL statements written with aliased tables.
public _track_aliases ( $table ) : string
Résultat string

_where() public méthode

Called by where() or orwhere()
public _where ( $key, $value = NULL, $type = 'AND ', $escape = NULL ) : object
Résultat object

_where_in() public méthode

Called by where_in, where_in_or, where_not_in, where_not_in_or
public _where_in ( $key = NULL, $values = NULL, $not = FALSE, $type = 'AND ' ) : object
Résultat object

count_all_results() public méthode

Generates a platform-specific query string that counts all records returned by an Active Record query.
public count_all_results ( $table = '' ) : string
Résultat string

dbprefix() public méthode

Prepends a database prefix if one exists in configuration
public dbprefix ( $table = '' ) : string
Résultat string

delete() public méthode

Compiles a delete string and runs the query
public delete ( $table = '', $where = '', $limit = NULL, $reset_data = TRUE ) : object
Résultat object

distinct() public méthode

Sets a flag which tells the query string compiler to add DISTINCT
public distinct ( $val = TRUE ) : object
Résultat object

empty_table() public méthode

Compiles a delete string and runs "DELETE FROM table"
public empty_table ( $table = '' ) : object
Résultat object

flush_cache() public méthode

Empties the AR cache
public flush_cache ( ) : void
Résultat void

from() public méthode

Generates the FROM portion of the query
public from ( $from ) : object
Résultat object

get() public méthode

Compiles the select statement based on the other functions called and runs the query
public get ( $table = '', $limit = null, $offset = null ) : object
Résultat object

get_where() public méthode

Allows the where clause, limit and offset to be added directly
public get_where ( $table = '', $where = null, $limit = null, $offset = null ) : object
Résultat object

getwhere() public méthode

getwhere() is an alias of get_where() this function is here for backwards compatibility, as getwhere() has been deprecated
public getwhere ( $table = '', $where = null, $limit = null, $offset = null )

group_by() public méthode

GROUP BY
public group_by ( $by ) : object
Résultat object

groupby() public méthode

groupby() is an alias of group_by() this function is here for backwards compatibility, as groupby() has been deprecated
public groupby ( $by )

having() public méthode

Separates multiple calls with AND
public having ( $key, $value = '', $escape = TRUE ) : object
Résultat object

insert() public méthode

Compiles an insert string and runs the query
public insert ( $table = '', $set = NULL ) : object
Résultat object

insert_batch() public méthode

Compiles batch insert strings and runs the queries
public insert_batch ( $table = '', $set = NULL ) : object
Résultat object

join() public méthode

Generates the JOIN portion of the query
public join ( $table, $cond, $type = '' ) : object
Résultat object

like() public méthode

Generates a %LIKE% portion of the query. Separates multiple calls with AND
public like ( $field, $match = '', $side = 'both' ) : object
Résultat object

limit() public méthode

Sets the LIMIT value
public limit ( $value, $offset = '' ) : object
Résultat object

not_like() public méthode

Generates a NOT LIKE portion of the query. Separates multiple calls with AND
public not_like ( $field, $match = '', $side = 'both' ) : object
Résultat object

offset() public méthode

Sets the OFFSET value
public offset ( $offset ) : object
Résultat object

or_having() public méthode

Separates multiple calls with OR
public or_having ( $key, $value = '', $escape = TRUE ) : object
Résultat object

or_like() public méthode

Generates a %LIKE% portion of the query. Separates multiple calls with OR
public or_like ( $field, $match = '', $side = 'both' ) : object
Résultat object

or_not_like() public méthode

Generates a NOT LIKE portion of the query. Separates multiple calls with OR
public or_not_like ( $field, $match = '', $side = 'both' ) : object
Résultat object

or_where() public méthode

Generates the WHERE portion of the query. Separates multiple calls with OR
public or_where ( $key, $value = NULL, $escape = TRUE ) : object
Résultat object

or_where_in() public méthode

Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate
public or_where_in ( $key = NULL, $values = NULL ) : object
Résultat object

or_where_not_in() public méthode

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with OR if appropriate
public or_where_not_in ( $key = NULL, $values = NULL ) : object
Résultat object

order_by() public méthode

Sets the ORDER BY value
public order_by ( $orderby, $direction = '' ) : object
Résultat object

orderby() public méthode

orderby() is an alias of order_by() this function is here for backwards compatibility, as orderby() has been deprecated
public orderby ( $orderby, $direction = '' )

orhaving() public méthode

orhaving() is an alias of or_having() this function is here for backwards compatibility, as orhaving() has been deprecated
public orhaving ( $key, $value = '', $escape = TRUE )

orlike() public méthode

orlike() is an alias of or_like() this function is here for backwards compatibility, as orlike() has been deprecated
public orlike ( $field, $match = '', $side = 'both' )

orwhere() public méthode

orwhere() is an alias of or_where() this function is here for backwards compatibility, as orwhere() has been deprecated
public orwhere ( $key, $value = NULL, $escape = TRUE )

replace() public méthode

public replace ( $table = '', $set = NULL )

select() public méthode

Generates the SELECT portion of the query
public select ( $select = '*', $escape = NULL ) : object
Résultat object

select_avg() public méthode

Generates a SELECT AVG(field) portion of a query
public select_avg ( $select = '', $alias = '' ) : object
Résultat object

select_max() public méthode

Generates a SELECT MAX(field) portion of a query
public select_max ( $select = '', $alias = '' ) : object
Résultat object

select_min() public méthode

Generates a SELECT MIN(field) portion of a query
public select_min ( $select = '', $alias = '' ) : object
Résultat object

select_sum() public méthode

Generates a SELECT SUM(field) portion of a query
public select_sum ( $select = '', $alias = '' ) : object
Résultat object

set() public méthode

The "set" function. Allows key/value pairs to be set for inserting or updating
public set ( $key, $value = '', $escape = TRUE ) : object
Résultat object

set_insert_batch() public méthode

The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts
public set_insert_batch ( $key, $value = '', $escape = TRUE ) : object
Résultat object

set_update_batch() public méthode

The "set_update_batch" function. Allows key/value pairs to be set for batch updating
public set_update_batch ( $key, $index = '', $escape = TRUE ) : object
Résultat object

start_cache() public méthode

Starts AR caching
public start_cache ( ) : void
Résultat void

stop_cache() public méthode

Stops AR caching
public stop_cache ( ) : void
Résultat void

truncate() public méthode

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 truncate ( $table = '' ) : object
Résultat object

update() public méthode

Compiles an update string and runs the query
public update ( $table = '', $set = NULL, $where = NULL, $limit = NULL ) : object
Résultat object

update_batch() public méthode

Compiles an update string and runs the query
public update_batch ( $table = '', $set = NULL, $index = NULL ) : object
Résultat object

where() public méthode

Generates the WHERE portion of the query. Separates multiple calls with AND
public where ( $key, $value = NULL, $escape = TRUE ) : object
Résultat object

where_in() public méthode

Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate
public where_in ( $key = NULL, $values = NULL ) : object
Résultat object

where_not_in() public méthode

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with AND if appropriate
public where_not_in ( $key = NULL, $values = NULL ) : object
Résultat object

Property Details

$ar_aliased_tables public_oe property

public $ar_aliased_tables

$ar_cache_exists public_oe property

public $ar_cache_exists

$ar_cache_from public_oe property

public $ar_cache_from

$ar_cache_groupby public_oe property

public $ar_cache_groupby

$ar_cache_having public_oe property

public $ar_cache_having

$ar_cache_join public_oe property

public $ar_cache_join

$ar_cache_like public_oe property

public $ar_cache_like

$ar_cache_orderby public_oe property

public $ar_cache_orderby

$ar_cache_select public_oe property

public $ar_cache_select

$ar_cache_set public_oe property

public $ar_cache_set

$ar_cache_where public_oe property

public $ar_cache_where

$ar_caching public_oe property

Active Record Caching variables
public $ar_caching

$ar_distinct public_oe property

public $ar_distinct

$ar_from public_oe property

public $ar_from

$ar_groupby public_oe property

public $ar_groupby

$ar_having public_oe property

public $ar_having

$ar_join public_oe property

public $ar_join

$ar_like public_oe property

public $ar_like

$ar_limit public_oe property

public $ar_limit

$ar_offset public_oe property

public $ar_offset

$ar_order public_oe property

public $ar_order

$ar_orderby public_oe property

public $ar_orderby

$ar_select public_oe property

public $ar_select

$ar_set public_oe property

public $ar_set

$ar_store_array public_oe property

public $ar_store_array

$ar_where public_oe property

public $ar_where

$ar_wherein public_oe property

public $ar_wherein