commit_transaction()
count_last_query()
count_records()
datatype()
delete()
error_info()
escape()
expr()
identifier()
in_transaction()
insert()
instance()
last_query()
list_columns()
list_indexes()
list_tables()
query()
quote()
quote_identifier()
quote_table()
rollback_transaction()
select()
select_array()
set_charset()
start_transaction()
table_prefix()
update()
$query_count
DELETE
INSERT
SELECT
UPDATE
commit_transaction(string $db) : bool
DB::commit_transaction();
stringdb connection
boolcount_last_query(string $db) : integer
// Get the total number of records that match the last query $count = $db->count_last_query();
stringdb connection
integercount_records(mixed $table, string $db) : integer
// Get the total number of records in the "users" table $count = DB::count_records('users');
mixedtable name string or array(query, alias)
stringdb connection
integerdatatype(string $type, string $db) : array
DB::datatype('char');
stringSQL data type
stringdb connection
arraydelete(string $table) : \Fuel\Core\Database_Query_Builder_Delete
// DELETE FROM users $query = DB::delete('users');
stringtable to delete from
error_info($db)
escape(string $string, string $db) : string
stringthe string to escape
stringthe database connection to use
stringthe escaped stringexpr(string $string) : \Fuel\Core\Database_Expression
An expression is the only way to use SQL functions within query builders.
$expression = DB::expr('COUNT(users.id)');
stringexpression
identifier(string $string, string $db) : \Fuel\Core\Database_Expression
An expression is the only way to use SQL functions within query builders.
$expression = DB::identifier('users.id'); // returns `users`.`id` for MySQL
stringthe string to quote
stringthe database connection to use
in_transaction(string $db) : bool
DB::in_transaction();
stringdb connection
boolinsert(string $table, array $columns) : \Fuel\Core\Database_Query_Builder_Insert
// INSERT INTO users (id, username) $query = DB::insert('users', array('id', 'username'));
stringtable to insert into
arraylist of column names or array($column, $alias) or object
instance($db)
last_query($db)
list_columns(string $table, string $like, string $db) : array
Optionally, a LIKE string can be used to search for specific fields.
// Get all columns from the "users" table
$columns = DB::list_columns('users');
// Get all name-related columns
$columns = DB::list_columns('users', '%name%');
stringtable to get columns from
stringcolumn to search for
stringthe database connection to use
arraylist_indexes(string $table, string $like, string $db) : array
Optionally, a LIKE string can be used to search for specific indexes by name.
// Get all indexes from the "users" table
$indexes = $db->list_indexes('users');
// Get all name-related columns
$indexes = $db->list_indexes('users', '%name%');
stringtable to get indexes from
stringindex names to search for
stringthe database connection to use
arraylist_tables($like, string $db) : string
If not, then just the prefix is returned
stringthe database connection to use
stringthe prefixed table name or the prefixquery(string $sql, integer $type) : \Fuel\Core\Database_Query
// Create a new SELECT query $query = DB::query('SELECT * FROM users');
// Create a new DELETE query
$query = DB::query('DELETE FROM users WHERE id = 5');
Specifying the type changes the returned result. When using
DB::SELECT, a [Database_Query_Result] will be returned.
DB::INSERT queries will return the insert id and number of rows.
For all other queries, the number of affected rows is returned.
stringSQL statement
integertype: DB::SELECT, DB::UPDATE, etc
quote(string $string, string $db) : string
stringthe string to quote
stringthe database connection to use
stringthe quoted valuequote_identifier(string $string, string $db) : string
stringthe string to quote
stringthe database connection to use
stringthe quoted identifierquote_table(string $string, string $db) : string
stringthe string to quote
stringthe database connection to use
stringthe quoted identifierrollback_transaction(string $db, $rollback_all) : bool
In this case system rollsback all queries and closes the transaction
DB::rollback_transaction();
stringconnection
boolselect(mixed $args) : \Fuel\Core\Database_Query_Builder_Select
Each argument will be
treated as a column. To generate a foo AS bar alias, use an array.
// SELECT id, username
$query = DB::select('id', 'username');
// SELECT id AS user_id
$query = DB::select(array('id', 'user_id'));
mixedcolumn name or array($column, $alias) or object
select_array(array $columns) : \Fuel\Core\Database_Query_Builder_Select
// SELECT id, username $query = DB::select_array(array('id', 'username'));
arraycolumns to select
set_charset(string $charset, string $db) : void
This is called automatically by [static::connect].
DB::set_charset('utf8');
stringcharacter set name
stringdb connection
\Fuel\Core\Database_Exception |
|---|
start_transaction(string $db) : bool
DB::start_transaction();
stringdb connection
booltable_prefix(string $table, string $db) : string
If not, then just the prefix is returned
stringthe table name to prefix
stringthe database connection to use
stringthe prefixed table name or the prefixupdate(string $table) : \Fuel\Core\Database_Query_Builder_Update
// UPDATE users $query = DB::update('users');
stringtable to update
$query_count
DELETE
INSERT
SELECT
UPDATE