Class: db
Database handling sucks - not with this class :)
Configure your database connection like this:
c::set('db.host', 'localhost');
c::set('db.user', 'root');
c::set('db.password', '');
c::set('db.name', 'mydb');
c::set('db.prefix', '');
Methods
-
db::affected
Returns the number of affected rows for the last query
-
db::charset
Sets the charset for all queries
The default and recommended charset is utf8 -
db::column
Returns all values from single column of a table
-
db::connect
The core connection method
Tries to connect to the server
Selects the database and sets the charset -
db::connection
Returns the current connection or false
-
db::count
Counts a number of rows in a table
-
db::database
Selects a database
-
db::delete
Runs a DELETE query
-
db::disconnect
Disconnects from the server
-
db::error
An internal error handler
-
db::escape
Escapes unwanted stuff in values like slashes, etc.
-
db::execute
Executes a MySQL query without result set.
-
db::fetch
Shortcut for mysql_fetch_array
-
db::field
Returns a single field value from a table
-
db::fields
Returns an array of fields in a given table
-
db::in
A simplifier to build IN clauses
-
db::insert
Runs a INSERT query
-
db::insert_all
Runs a INSERT query with values
-
db::join
Joins two tables and returns data from them
-
db::last_id
Returns the last returned insert id
-
db::left_join
Runs a LEFT JOIN
-
db::max
Gets the maximum value in a column of a table
-
db::min
Gets the minimum value in a column of a table
-
db::prefix
Adds a prefix to a table name if set in c::set('db.prefix', 'myprefix_');
This makes it possible to use table names in all methods without prefix
and it will still be applied automatically. -
db::query
Runs a MySQL query.
-
db::replace
Runs a REPLACE query
-
db::row
Returns a single row from a table
-
db::search_clause
A simplifier to build search clauses
-
db::select
Returns multiple rows from a table
-
db::select_clause
Builds a select clause from a simple array
-
db::simple_fields
Strips table specific column prefixes from the result array
-
db::sum
Gets the sum of values in a column of a table
-
db::update
Runs an UPDATE query
-
db::values
Makes it possible to use arrays for inputs instead of MySQL strings
-
db::where
A handler to convert key/value arrays to an where clause
-
db::with
An easy method to build a part of the where clause to find stuff by its first character