Model
extends CI_Model
in package
CI_Model extension.
Table of Contents
Constants
- TABLE = ''
- Table name.
Properties
- $library : string|array<string|int, string>
- Auto-loading library name.
- $model : string|array<string|int, string>
- Auto-loading model name.
Methods
- __construct() : mixed
- Initialize Model.
- cache_delete() : void
- Delete the cache files associated with a particular URI
- cache_delete_all() : void
- Delete All cache files.
- cache_off() : void
- Disable Query Caching.
- cache_on() : void
- Enable Query Caching.
- count_all() : int
- Returns the total number of rows in a table, or 0 if no table was provided.
- count_all_results() : int
- "Count All Results" query.
- count_by_id() : int
- Get counts matching ID.
- db() : CI_DB
- Get database object.
- dbprefix() : string
- DB Prefix. Prepends a database prefix if one exists in configuration
- delete() : CI_DB_query_builder
- Delete.
- distinct() : Model
- Sets a flag which tells the query string compiler to add DISTINCT.
- empty_table() : bool
- Empty Table.
- error() : array{code: string|null, message: string|null}
- Last error.
- escape() : mixed
- Escapes input data based on type, including boolean and NULLs.
- escape_like_str() : mixed
- Escape LIKE strings.
- escape_str() : string
- Escapes string values.
- exists_by_id() : bool
- Check if the ID exists.
- field_data() : array<string|int, mixed>
- Gets a list containing field data about a table.
- field_exists() : bool
- Determine if a particular field exists.
- flush_cache() : Model
- Flush Cache.
- from() : Model
- Generates the FROM portion of the query
- get() : CI_DB_result
- Compiles and runs SELECT statement based on the already called Query Builder methods.
- get_all() : array<string|int, mixed>
- Query result. "array" version.
- get_by_id() : array<string|int, mixed>
- Find records matching the ID.
- get_compiled_delete() : string
- Compiles a DELETE statement and returns it as a string.
- get_compiled_insert() : string
- Get INSERT query string.
- get_compiled_select() : string
- Compiles a SELECT statement and returns it as a string.
- get_compiled_update() : string
- Get UPDATE query string
- get_where() : CI_DB_result
- Allows the where clause, limit and offset to be added directly.
- group_by() : Model
- GROUP BY.
- group_end() : Model
- Ends a query group.
- group_start() : Model
- Starts a query group.
- having() : Model
- HAVING. Separates multiple calls with 'AND'.
- insert() : int
- Insert.
- insert_batch() : array<string|int, int>
- Insert_Batch.
- insert_id() : int
- Insert ID.
- insert_on_duplicate_update() : int
- Insert_On_Duplicate_Key_Update.
- insert_on_duplicate_update_batch() : int
- Insert_On_Duplicate_Key_Update_Batch.
- is_connect() : bool
- DB connection check
- join() : Model
- Generates the JOIN portion of the query
- last_query() : string
- Returns the last query that was executed.
- like() : Model
- Generates a %LIKE% portion of the query. Separates multiple calls with 'AND'.
- limit() : Model
- LIMIT.
- list_fields() : array<string|int, mixed>
- Gets a list of the field names in a table.
- list_tables() : array<string|int, mixed>
- Gets a list of the tables in the current database.
- load_rdriver() : string
- Load the result drivers.
- not_group_start() : Model
- Starts a query group, but NOTs the group.
- not_like() : Model
- Generates a NOT LIKE portion of the query. Separates multiple calls with 'AND'.
- offset() : Model
- Sets the OFFSET value.
- or_group_start() : Model
- Starts a query group, but ORs the group.
- or_having() : Model
- OR HAVING. Separates multiple calls with 'OR'.
- or_like() : Model
- Generates a %LIKE% portion of the query. Separates multiple calls with 'OR'.
- or_not_group_start() : Model
- Starts a query group, but OR NOTs the group.
- or_not_like() : Model
- Generates a NOT LIKE portion of the query. Separates multiple calls with 'OR'.
- or_where() : CI_DB_query_builder
- Generates the WHERE portion of the query. Separates multiple calls with 'OR'.
- or_where_in() : Model
- Generates a WHERE field IN('item', 'item') SQL query, joined with 'OR' if appropriate.
- or_where_not_in() : Model
- Generates a WHERE field NOT IN('item', 'item') SQL query, joined with 'OR' if appropriate.
- order_by() : Model
- ORDER BY.
- primary() : string
- Retrieves the primary key of a table.
- query() : mixed
- Execute the query.
- replace() : bool
- Replace.
- reset_query() : Model
- Reset Query Builder values.
- select() : Model
- Generates the SELECT portion of the query.
- select_avg() : Model
- Generates a SELECT AVG(field) portion of a query
- select_max() : Model
- Generates a SELECT MAX(field) portion of a query.
- select_min() : Model
- Generates a SELECT MIN(field) portion of a query
- select_sum() : Model
- Generates a SELECT SUM(field) portion of a query
- set() : Model
- Allows key/value pairs to be set for inserting or updating
- set_dbprefix() : string
- Set's the DB Prefix to something new without needing to reconnect
- set_foreign_key_checks() : bool
- Set foreign key check.
- set_insert_batch() : Model
- The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts.
- set_update_batch() : Model
- The "set_update_batch" function. Allows key/value pairs to be set for batch updating
- start_cache() : Model
- Starts QB caching.
- stop_cache() : Model
- Stops QB caching
- table_exists() : bool
- Determine if a particular table exists.
- trans_begin() : bool
- Begin Transaction.
- trans_commit() : bool
- Commit Transaction.
- trans_complete() : bool
- Complete Transaction.
- trans_rollback() : bool
- Rollback Transaction.
- trans_start() : bool
- Start Transaction.
- trans_status() : bool
- Lets you retrieve the transaction flag to determine if it has failed.
- truncate() : bool
- Truncate.
- update() : void
- Update.
- update_batch() : int
- Update_Batch.
- where() : Model
- Generates the WHERE portion of the query. Separates multiple calls with 'AND'.
- where_in() : Model
- Generates a WHERE field IN('item', 'item') SQL query, joined with 'AND' if appropriate.
- where_not_in() : Model
- Generates a WHERE field NOT IN('item', 'item') SQL query, joined with 'AND' if appropriate.
Constants
TABLE
Table name.
public
string
TABLE
= ''
Properties
$library
Auto-loading library name.
protected
string|array<string|int, string>
$library
$model
Auto-loading model name.
protected
string|array<string|int, string>
$model
Methods
__construct()
Initialize Model.
public
__construct() : mixed
cache_delete()
Delete the cache files associated with a particular URI
public
cache_delete([string $segmentOne = '' ][, string $segmentTwo = '' ]) : void
Parameters
- $segmentOne : string = ''
-
First URI segment.
- $segmentTwo : string = ''
-
Second URI segment.
cache_delete_all()
Delete All cache files.
public
cache_delete_all() : void
cache_off()
Disable Query Caching.
public
cache_off() : void
cache_on()
Enable Query Caching.
public
cache_on() : void
count_all()
Returns the total number of rows in a table, or 0 if no table was provided.
public
count_all([string $table = '' ]) : int
Parameters
- $table : string = ''
-
(optional) Table name.
Return values
int —Row count for the specified table.
count_all_results()
"Count All Results" query.
public
count_all_results([string $table = '' ][, bool $reset = true ]) : int
Generates a platform-specific query string that counts all records returned by an Query Builder query.
Parameters
- $table : string = ''
-
(optional) Table name.
- $reset : bool = true
-
Whether to reset values for SELECTs.
Return values
intcount_by_id()
Get counts matching ID.
public
count_by_id(int $id) : int
Parameters
- $id : int
-
ID.
Return values
int —Search result count.
db()
Get database object.
public
static db([string $config = 'default' ]) : CI_DB
Parameters
- $config : string = 'default'
-
Connection group name. Default is "default".
Return values
CI_DB —CI_DB instance.
dbprefix()
DB Prefix. Prepends a database prefix if one exists in configuration
public
dbprefix([string $table = '' ]) : string
Parameters
- $table : string = ''
-
(optional) The table name to prefix.
Return values
string —The prefixed table name.
delete()
Delete.
public
delete([string $table = '' ][, string $where = '' ][, int $limit = null ][, bool $reset = true ]) : CI_DB_query_builder
Parameters
- $table : string = ''
-
(optional) The table(s) to delete from; string or array.
- $where : string = ''
-
(optional) The WHERE clause.
- $limit : int = null
-
The (optional) LIMIT clause.
- $reset : bool = true
-
(optional) TRUE to reset the query "write" clause.
Return values
CI_DB_query_builder —instance (method chaining) or FALSE on failure.
distinct()
Sets a flag which tells the query string compiler to add DISTINCT.
public
distinct([bool $val = true ]) : Model
Parameters
- $val : bool = true
-
Desired value of the "distinct" flag.
Return values
Modelempty_table()
Empty Table.
public
empty_table([string $table = '' ]) : bool
Parameters
- $table : string = ''
-
(optional) Table name.
Return values
bool —true on success, false on failure.
error()
Last error.
public
error() : array{code: string|null, message: string|null}
Return values
array{code: string|null, message: string|null} —Error data.
escape()
Escapes input data based on type, including boolean and NULLs.
public
escape(mixed $str) : mixed
Parameters
- $str : mixed
-
The value to escape, or an array of multiple ones.
Return values
mixed —The escaped value(s).
escape_like_str()
Escape LIKE strings.
public
escape_like_str(string|array<string|int, string> $str) : mixed
Parameters
- $str : string|array<string|int, string>
-
A string value or array of multiple ones.
Return values
mixed —The escaped string(s).
escape_str()
Escapes string values.
public
escape_str(string|array<string|int, string> $str[, bool $like = false ]) : string
Parameters
- $str : string|array<string|int, string>
-
A string value or array of multiple ones.
- $like : bool = false
-
(optional) Whether or not the string will be used in a LIKE condition.
Return values
string —The escaped string(s).
exists_by_id()
Check if the ID exists.
public
exists_by_id(int $id) : bool
Parameters
- $id : int
-
ID.
Return values
bool —Whether the ID exists.
field_data()
Gets a list containing field data about a table.
public
field_data([string $table = null ]) : array<string|int, mixed>
Parameters
- $table : string = null
-
(optional) The table name.
Return values
array<string|int, mixed> —Array of field data items or FALSE on failure.
field_exists()
Determine if a particular field exists.
public
field_exists(string $field[, string $table = null ]) : bool
Parameters
- $field : string
-
The field name.
- $table : string = null
-
(optional) The table name.
Return values
bool —TRUE if that field exists in that table, FALSE if not
flush_cache()
Flush Cache.
public
flush_cache() : Model
Empties the QB cache.
Return values
Modelfrom()
Generates the FROM portion of the query
public
from(mixed $from) : Model
Parameters
- $from : mixed
-
Table name(s); string or array.
Return values
Modelget()
Compiles and runs SELECT statement based on the already called Query Builder methods.
public
get([string $table = '' ][, string $limit = null ][, string $offset = null ]) : CI_DB_result
Parameters
- $table : string = ''
-
(optional) The table to query.
- $limit : string = null
-
(optional) The LIMIT clause.
- $offset : string = null
-
(optional) The OFFSET clause.
Return values
CI_DB_resultget_all()
Query result. "array" version.
public
get_all() : array<string|int, mixed>
Return values
array<string|int, mixed> —Search result data.
get_by_id()
Find records matching the ID.
public
get_by_id(int $id) : array<string|int, mixed>
Parameters
- $id : int
-
ID.
Return values
array<string|int, mixed> —Search result data.
get_compiled_delete()
Compiles a DELETE statement and returns it as a string.
public
get_compiled_delete([string $table = '' ][, bool $reset = true ]) : string
Parameters
- $table : string = ''
-
(optional) Table name.
- $reset : bool = true
-
(optional) Whether to reset the current QB values or not.
Return values
string —The compiled SQL statement as a string.
get_compiled_insert()
Get INSERT query string.
public
get_compiled_insert([string $table = '' ][, bool $reset = true ]) : string
Parameters
- $table : string = ''
-
(optional) Table name.
- $reset : bool = true
-
(optional) Whether to reset the current QB values or not.
Return values
string —Compiles an INSERT statement and returns it as a string.
get_compiled_select()
Compiles a SELECT statement and returns it as a string.
public
get_compiled_select([string $table = '' ][, bool $reset = true ]) : string
Parameters
- $table : string = ''
-
(optional) Table name.
- $reset : bool = true
-
(optional) Whether to reset the current QB values or not.
Return values
string —The compiled SQL statement as a string.
get_compiled_update()
Get UPDATE query string
public
get_compiled_update([string $table = '' ][, bool $reset = true ]) : string
Parameters
- $table : string = ''
-
(optional) Table name.
- $reset : bool = true
-
(optional) Whether to reset the current QB values or not.
Return values
string —The compiled SQL statement as a string.
get_where()
Allows the where clause, limit and offset to be added directly.
public
get_where([string $table = '' ][, string $where = null ][, int $limit = null ][, int $offset = null ]) : CI_DB_result
Parameters
- $table : string = ''
-
(optional) The table(s) to fetch data from; string or array.
- $where : string = null
-
(optional) The WHERE clause.
- $limit : int = null
-
(optional) The LIMIT clause.
- $offset : int = null
-
(optional) The OFFSET clause.
Return values
CI_DB_resultgroup_by()
GROUP BY.
public
group_by(string $by[, bool $escape = null ]) : Model
Parameters
- $by : string
-
Field(s) to group by; string or array.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelgroup_end()
Ends a query group.
public
group_end() : Model
Return values
Modelgroup_start()
Starts a query group.
public
group_start([string $not = '' ][, string $type = 'AND ' ]) : Model
Parameters
- $not : string = ''
-
(Internal use only).
- $type : string = 'AND '
-
(Internal use only).
Return values
Modelhaving()
HAVING. Separates multiple calls with 'AND'.
public
having(string $key[, string $value = null ][, bool $escape = null ]) : Model
Parameters
- $key : string
-
Identifier (string) or associative array of field/value pairs.
- $value : string = null
-
Value sought if $key is an identifier.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelinsert()
Insert.
public
insert([string $table = '' ][, array<string|int, mixed>|object $set = null ][, bool $escape = null ]) : int
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) An associative array of field/value pairs.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
int —Insert ID.
insert_batch()
Insert_Batch.
public
insert_batch(string $table[, array<string|int, mixed>|object $set = null ][, bool $escape = null ][, int $batchSize = 100 ]) : array<string|int, int>
Parameters
- $table : string
-
Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) Data to insert.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
- $batchSize : int = 100
-
(optional) Count of rows to insert at once. Default is 100.
Return values
array<string|int, int> —Insert ID.
insert_id()
Insert ID.
public
insert_id() : int
Return values
int —Insert ID.
insert_on_duplicate_update()
Insert_On_Duplicate_Key_Update.
public
insert_on_duplicate_update([string $table = '' ][, array<string|int, mixed>|object $set = null ][, bool $escape = null ]) : int
$SampleModel
->set([
'key' => '1',
'title' => 'My title',
'name' => 'My Name'
])
->insert_on_duplicate_update();
$SampleModel
->set('key', '1')
->set('title', 'My title')
->set('name', 'My Name')
->insert_on_duplicate_update();
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) an associative array of insert values.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
int —Insert ID.
insert_on_duplicate_update_batch()
Insert_On_Duplicate_Key_Update_Batch.
public
insert_on_duplicate_update_batch([string $table = '' ][, array<string|int, mixed>|object $set = null ][, bool $escape = null ][, int $batchSize = 100 ]) : int
$SampleModel
->set_insert_batch([
['key' => '1', 'title' => 'My title', 'name' => 'My Name'],
['key' => '2', 'title' => 'Another title', 'name' => 'Another Name']
])
->insert_on_duplicate_update_batch();
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) an associative array of insert values.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
- $batchSize : int = 100
-
(optional) Count of rows to insert at once. Default is 100.
Return values
int —Number of rows inserted or false on failure.
is_connect()
DB connection check
public
static is_connect([string $config = 'default' ]) : bool
Parameters
- $config : string = 'default'
-
Connection group name. Default is "default".
Return values
bool —Whether you could connect to DB or not.
join()
Generates the JOIN portion of the query
public
join(string $table, string $cond[, string $type = '' ][, bool $escape = null ]) : Model
Parameters
- $table : string
-
Table name.
- $cond : string
-
The JOIN ON condition.
- $type : string = ''
-
(optional) The JOIN type.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modellast_query()
Returns the last query that was executed.
public
last_query() : string
Return values
string —The last query executed.
like()
Generates a %LIKE% portion of the query. Separates multiple calls with 'AND'.
public
like(mixed $field[, string $match = '' ][, string $side = 'both' ][, bool $escape = null ]) : Model
Parameters
- $field : mixed
-
Field name.
- $match : string = ''
-
(optional) Text portion to match.
- $side : string = 'both'
-
(optional) Which side of the expression to put the ‘%’ wildcard on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modellimit()
LIMIT.
public
limit(int $value[, int $offset = 0 ]) : Model
Parameters
- $value : int
-
Number of rows to limit the results to.
- $offset : int = 0
-
Number of rows to skip.
Return values
Modellist_fields()
Gets a list of the field names in a table.
public
list_fields([string $table = null ]) : array<string|int, mixed>
Parameters
- $table : string = null
-
(optional) The table name.
Return values
array<string|int, mixed> —Array of field names or FALSE on failure.
list_tables()
Gets a list of the tables in the current database.
public
list_tables([string $constrainByPrefix = false ]) : array<string|int, mixed>
Parameters
- $constrainByPrefix : string = false
-
(optional) TRUE to match table names by the configured dbprefix.
Return values
array<string|int, mixed> —Array of table names or FALSE on failure.
load_rdriver()
Load the result drivers.
public
load_rdriver() : string
Return values
string —the name of the result class.
not_group_start()
Starts a query group, but NOTs the group.
public
not_group_start() : Model
Return values
Modelnot_like()
Generates a NOT LIKE portion of the query. Separates multiple calls with 'AND'.
public
not_like(mixed $field[, string $match = '' ][, string $side = 'both' ][, bool $escape = null ]) : Model
Parameters
- $field : mixed
-
Field name.
- $match : string = ''
-
(optional) Text portion to match.
- $side : string = 'both'
-
(optional) Which side of the expression to put the ‘%’ wildcard on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modeloffset()
Sets the OFFSET value.
public
offset(int $offset) : Model
Parameters
- $offset : int
-
Number of rows to skip.
Return values
Modelor_group_start()
Starts a query group, but ORs the group.
public
or_group_start() : Model
Return values
Modelor_having()
OR HAVING. Separates multiple calls with 'OR'.
public
or_having(string $key[, string $value = null ][, bool $escape = null ]) : Model
Parameters
- $key : string
-
Identifier (string) or associative array of field/value pairs.
- $value : string = null
-
Value sought if $key is an identifier.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelor_like()
Generates a %LIKE% portion of the query. Separates multiple calls with 'OR'.
public
or_like(mixed $field[, string $match = '' ][, string $side = 'both' ][, bool $escape = null ]) : Model
Parameters
- $field : mixed
-
Field name.
- $match : string = ''
-
(optional) Text portion to match.
- $side : string = 'both'
-
(optional) Which side of the expression to put the ‘%’ wildcard on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelor_not_group_start()
Starts a query group, but OR NOTs the group.
public
or_not_group_start() : Model
Return values
Modelor_not_like()
Generates a NOT LIKE portion of the query. Separates multiple calls with 'OR'.
public
or_not_like(mixed $field[, string $match = '' ][, string $side = 'both' ][, bool $escape = null ]) : Model
Parameters
- $field : mixed
-
Field name.
- $match : string = ''
-
(optional) Text portion to match.
- $side : string = 'both'
-
(optional) Which side of the expression to put the ‘%’ wildcard on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelor_where()
Generates the WHERE portion of the query. Separates multiple calls with 'OR'.
public
or_where(string $key[, mixed $value = null ][, bool $escape = null ]) : CI_DB_query_builder
Parameters
- $key : string
-
Name of field to compare, or associative array.
- $value : mixed = null
-
(optional) If a single key, compared to this value.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
CI_DB_query_builderor_where_in()
Generates a WHERE field IN('item', 'item') SQL query, joined with 'OR' if appropriate.
public
or_where_in([string $key = null ][, array<string|int, mixed> $values = null ][, bool $escape = null ]) : Model
Parameters
- $key : string = null
-
(optional) The field to search.
- $values : array<string|int, mixed> = null
-
(optional) The values searched on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelor_where_not_in()
Generates a WHERE field NOT IN('item', 'item') SQL query, joined with 'OR' if appropriate.
public
or_where_not_in([string $key = null ][, array<string|int, mixed> $values = null ][, bool $escape = null ]) : Model
Parameters
- $key : string = null
-
(optional) The field to search.
- $values : array<string|int, mixed> = null
-
(optional) The values searched on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelorder_by()
ORDER BY.
public
order_by(string $orderby[, string $direction = '' ][, bool $escape = null ]) : Model
Parameters
- $orderby : string
-
Field to order by.
- $direction : string = ''
-
The order requested - ASC, DESC or random.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelprimary()
Retrieves the primary key of a table.
public
primary([string $table = null ]) : string
Parameters
- $table : string = null
-
(optional) Table name.
Return values
string —The primary key name, FALSE if none.
query()
Execute the query.
public
query(string $sql[, array<string|int, mixed>|false $binds = false ][, bool $returnObject = null ]) : mixed
Parameters
- $sql : string
-
The SQL statement to execute.
- $binds : array<string|int, mixed>|false = false
-
(optional) An array of binding data.
- $returnObject : bool = null
-
(optional) Whether to return a result object or not.
Return values
mixed —true for successful "write-type" queries, CI_DB_result instance (method chaining) on "query" success, false on failure.
replace()
Replace.
public
replace([string $table = '' ][, array<string|int, mixed>|null $set = null ]) : bool
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|null = null
-
(optional) An associative array of field/value pairs.
Return values
bool —true on success, false on failure.
reset_query()
Reset Query Builder values.
public
reset_query() : Model
Publicly-visible method to reset the QB values.
Return values
Modelselect()
Generates the SELECT portion of the query.
public
select([string $select = '*' ][, bool $escape = null ]) : Model
Parameters
- $select : string = '*'
-
(optional) The SELECT portion of a query.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelselect_avg()
Generates a SELECT AVG(field) portion of a query
public
select_avg([string $select = '' ][, string $alias = '' ]) : Model
Parameters
- $select : string = ''
-
(optional) Field to compute the average of.
- $alias : string = ''
-
(optional) Alias for the resulting value name.
Return values
Modelselect_max()
Generates a SELECT MAX(field) portion of a query.
public
select_max([string $select = '' ][, string $alias = '' ]) : Model
Parameters
- $select : string = ''
-
(optional) Field to compute the maximum of.
- $alias : string = ''
-
(optional) Alias for the resulting value name.
Return values
Modelselect_min()
Generates a SELECT MIN(field) portion of a query
public
select_min([string $select = '' ][, string $alias = '' ]) : Model
Parameters
- $select : string = ''
-
(optional) Field to compute the minimum of.
- $alias : string = ''
-
(optional) Alias for the resulting value name.
Return values
Modelselect_sum()
Generates a SELECT SUM(field) portion of a query
public
select_sum([string $select = '' ][, string $alias = '' ]) : Model
Parameters
- $select : string = ''
-
(optional) Field to compute the sum of.
- $alias : string = ''
-
(optional) Alias for the resulting value name.
Return values
Modelset()
Allows key/value pairs to be set for inserting or updating
public
set(mixed $key[, string $value = '' ][, bool $escape = null ]) : Model
Parameters
- $key : mixed
-
Field name, or an array of field/value pairs.
- $value : string = ''
-
(optional) Field value, if $key is a single field.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelset_dbprefix()
Set's the DB Prefix to something new without needing to reconnect
public
set_dbprefix([string $prefix = '' ]) : string
Parameters
- $prefix : string = ''
-
The new prefix to use.
Return values
string —The DB prefix in use.
set_foreign_key_checks()
Set foreign key check.
public
set_foreign_key_checks(bool $enabled) : bool
Parameters
- $enabled : bool
-
Value of foreign_key_checks.
Return values
bool —TRUE on success, FALSE on failure.
set_insert_batch()
The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts.
public
set_insert_batch(mixed $key[, string $value = '' ][, bool $escape = null ]) : Model
Parameters
- $key : mixed
-
Field name or an array of field/value pairs.
- $value : string = ''
-
(optional) Field value, if $key is a single field.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelset_update_batch()
The "set_update_batch" function. Allows key/value pairs to be set for batch updating
public
set_update_batch(array<string|int, mixed> $key[, string $value = '' ][, bool $escape = null ]) : Model
Parameters
- $key : array<string|int, mixed>
-
Field name or an array of field/value pairs.
- $value : string = ''
-
(optional) Field value, if $key is a single field.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelstart_cache()
Starts QB caching.
public
start_cache() : Model
Return values
Modelstop_cache()
Stops QB caching
public
stop_cache() : Model
Return values
Modeltable_exists()
Determine if a particular table exists.
public
table_exists([string $table = null ]) : bool
Parameters
- $table : string = null
-
(optional) The table name.
Return values
bool —TRUE if that table exists, FALSE if not.
trans_begin()
Begin Transaction.
public
trans_begin([bool $testMode = false ]) : bool
Parameters
- $testMode : bool = false
-
(optional) Test mode flag.
Return values
bool —TRUE on success, FALSE on failure.
trans_commit()
Commit Transaction.
public
trans_commit() : bool
Return values
bool —TRUE on success, FALSE on failure.
trans_complete()
Complete Transaction.
public
trans_complete() : bool
Return values
bool —TRUE on success, FALSE on failure.
trans_rollback()
Rollback Transaction.
public
trans_rollback() : bool
Return values
bool —TRUE on success, FALSE on failure.
trans_start()
Start Transaction.
public
trans_start([bool $testMode = false ]) : bool
Parameters
- $testMode : bool = false
-
(optional) Test mode flag.
Return values
bool —TRUE on success, FALSE on failure.
trans_status()
Lets you retrieve the transaction flag to determine if it has failed.
public
trans_status() : bool
Return values
bool —TRUE if the transaction succeeded, FALSE if it failed.
truncate()
Truncate.
public
truncate([string $table = '' ]) : bool
Parameters
- $table : string = ''
-
(optional) Table name.
Return values
bool —true on success, false on failure.
update()
Update.
public
update([string $table = '' ][, array<string|int, mixed>|object $set = null ][, string|array<string|int, mixed> $where = null ][, int $limit = null ]) : void
Parameters
- $table : string = ''
-
(optional) Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) An associative array of field/value pairs.
- $where : string|array<string|int, mixed> = null
-
(optional) The WHERE clause.
- $limit : int = null
-
(optional) The LIMIT clause.
update_batch()
Update_Batch.
public
update_batch(string $table[, array<string|int, mixed>|object $set = null ][, string $value = null ][, int $batchSize = 100 ]) : int
Parameters
- $table : string
-
Table name.
- $set : array<string|int, mixed>|object = null
-
(optional) Field name, or an associative array of field/value pairs.
- $value : string = null
-
(optional) Field value, if $set is a single field.
- $batchSize : int = 100
-
(optional) Count of rows to update at once. Default is 100.
Return values
int —Number of rows updated or FALSE on failure
where()
Generates the WHERE portion of the query. Separates multiple calls with 'AND'.
public
where(string $key[, mixed $value = null ][, bool $escape = null ]) : Model
Parameters
- $key : string
-
Name of field to compare, or associative array.
- $value : mixed = null
-
(optional) If a single key, compared to this value.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelwhere_in()
Generates a WHERE field IN('item', 'item') SQL query, joined with 'AND' if appropriate.
public
where_in([string $key = null ][, array<string|int, mixed> $values = null ][, bool $escape = null ]) : Model
Parameters
- $key : string = null
-
(optional) The field to search.
- $values : array<string|int, mixed> = null
-
(optional) The values searched on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.
Return values
Modelwhere_not_in()
Generates a WHERE field NOT IN('item', 'item') SQL query, joined with 'AND' if appropriate.
public
where_not_in([string $key = null ][, array<string|int, mixed> $values = null ][, bool $escape = null ]) : Model
Parameters
- $key : string = null
-
(optional) The field to search.
- $values : array<string|int, mixed> = null
-
(optional) The values searched on.
- $escape : bool = null
-
(optional) Whether to escape values and identifiers.