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();
string
db connection
bool
count_last_query(string $db) : integer
// Get the total number of records that match the last query $count = $db->count_last_query();
string
db connection
integer
count_records(mixed $table, string $db) : integer
// Get the total number of records in the "users" table $count = DB::count_records('users');
mixed
table name string or array(query, alias)
string
db connection
integer
datatype(string $type, string $db) : array
DB::datatype('char');
string
SQL data type
string
db connection
array
delete(string $table) : \Fuel\Core\Database_Query_Builder_Delete
// DELETE FROM users $query = DB::delete('users');
string
table to delete from
error_info($db)
escape(string $string, string $db) : string
string
the string to escape
string
the database connection to use
string
the 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)');
string
expression
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
string
the string to quote
string
the database connection to use
in_transaction(string $db) : bool
DB::in_transaction();
string
db connection
bool
insert(string $table, array $columns) : \Fuel\Core\Database_Query_Builder_Insert
// INSERT INTO users (id, username) $query = DB::insert('users', array('id', 'username'));
string
table to insert into
array
list 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%');
string
table to get columns from
string
column to search for
string
the database connection to use
array
list_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%');
string
table to get indexes from
string
index names to search for
string
the database connection to use
array
list_tables($like, string $db) : string
If not, then just the prefix is returned
string
the database connection to use
string
the 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.
string
SQL statement
integer
type: DB::SELECT, DB::UPDATE, etc
quote(string $string, string $db) : string
string
the string to quote
string
the database connection to use
string
the quoted valuequote_identifier(string $string, string $db) : string
string
the string to quote
string
the database connection to use
string
the quoted identifierquote_table(string $string, string $db) : string
string
the string to quote
string
the database connection to use
string
the quoted identifierrollback_transaction(string $db, $rollback_all) : bool
In this case system rollsback all queries and closes the transaction
DB::rollback_transaction();
string
connection
bool
select(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'));
mixed
column 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'));
array
columns to select
set_charset(string $charset, string $db) : void
This is called automatically by [static::connect].
DB::set_charset('utf8');
string
character set name
string
db connection
\Fuel\Core\Database_Exception |
---|
start_transaction(string $db) : bool
DB::start_transaction();
string
db connection
bool
table_prefix(string $table, string $db) : string
If not, then just the prefix is returned
string
the table name to prefix
string
the database connection to use
string
the prefixed table name or the prefixupdate(string $table) : \Fuel\Core\Database_Query_Builder_Update
// UPDATE users $query = DB::update('users');
string
table to update
$query_count
DELETE
INSERT
SELECT
UPDATE