Property | Type | Description | |
---|---|---|---|
$trace | array | Traces all db queries |
Method | Description | |
---|---|---|
affected ( ) : integer | Returns the number of affected rows for the last query | |
charset ( string $charset = 'utf8' ) : mixed | Sets the charset for all queries The default and recommended charset is utf8 | |
column ( string $table, string $column, mixed $where = null, string $order = null, integer $page = null, integer $limit = null ) : mixed | Returns all values from single column of a table | |
connect ( ) : mixed | The core connection method Tries to connect to the server Selects the database and sets the charset | |
connection ( ) : mixed | Returns the current connection or false | |
count ( string $table, mixed $where = '' ) : integer | Counts a number of rows in a table | |
database ( string $database ) : mixed | Selects a database | |
delete ( string $table, mixed $where = '' ) : mixed | Runs a DELETE query | |
disconnect ( ) : boolean | Disconnects from the server | |
error ( string $msg = null, boolean $exit = false ) : mixed | An internal error handler | |
escape ( string $value ) : string | Escapes unwanted stuff in values like slashes, etc. | |
execute ( string $sql ) : mixed | Executes a MySQL query without result set. | |
fetch ( resource $result, const $type = MYSQL_ASSOC ) : array | Shortcut for mysql_fetch_array | |
field ( string $table, string $field, mixed $where = null, string $order = null ) : mixed | Returns a single field value from a table | |
fields ( string $table ) : array | Returns an array of fields in a given table | |
in ( array $array ) : string | A simplifier to build IN clauses | |
insert ( string $table, mixed $input, boolean $ignore = false ) : mixed | Runs a INSERT query | |
insert_all ( string $table, array $fields, array $values ) : mixed | Runs a INSERT query with values | |
join ( string $table_1, string $table_2, string $on, mixed $select, mixed $where = null, string $order = null, integer $page = null, integer $limit = null, string $type = "JOIN" ) : mixed | Joins two tables and returns data from them | |
last_id ( ) : integer | Returns the last returned insert id | |
left_join ( string $table_1, string $table_2, string $on, mixed $select, mixed $where = null, string $order = null, integer $page = null, integer $limit = null ) : mixed | Runs a LEFT JOIN | |
max ( string $table, string $column, mixed $where = null ) : mixed | Gets the maximum value in a column of a table | |
min ( string $table, string $column, mixed $where = null ) : mixed | Gets the minimum value in a column of a table | |
prefix ( string $table ) : string | 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. | |
query ( string $sql, boolean $fetch = true ) : mixed | Runs a MySQL query. | |
replace ( string $table, mixed $input ) : mixed | Runs a REPLACE query | |
row ( string $table, mixed $select = '*', mixed $where = null, string $order = null ) : mixed | Returns a single row from a table | |
search_clause ( string $search, array $fields, string $mode = 'OR' ) : string | A simplifier to build search clauses | |
select ( string $table, mixed $select = '*', mixed $where = null, string $order = null, integer $page = null, integer $limit = null, boolean $fetch = true ) : mixed | Returns multiple rows from a table | |
select_clause ( $fields ) : string | Builds a select clause from a simple array | |
simple_fields ( array $array ) : array | Strips table specific column prefixes from the result array | |
sum ( string $table, string $column, mixed $where = null ) : mixed | Gets the sum of values in a column of a table | |
update ( string $table, mixed $input, mixed $where ) : mixed | Runs an UPDATE query | |
values ( array $input ) : string | Makes it possible to use arrays for inputs instead of MySQL strings | |
where ( array $array, string $method = 'AND' ) : string | A handler to convert key/value arrays to an where clause | |
with ( string $field, string $char ) : string | An easy method to build a part of the where clause to find stuff by its first character |
static public column ( string $table, string $column, mixed $where = null, string $order = null, integer $page = null, integer $limit = null ) : mixed | ||
$table | string | The table name |
$column | string | The name of the column |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
$order | string | Order clause without the order keyword. ie: "added desc" |
$page | integer | a page number |
$limit | integer | a number for rows to return |
return | mixed |
static public connection ( ) : mixed | ||
return | mixed |
static public disconnect ( ) : boolean | ||
return | boolean |
static public field ( string $table, string $field, mixed $where = null, string $order = null ) : mixed | ||
$table | string | The table name |
$field | string | The name of the field |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
$order | string | Order clause without the order keyword. ie: "added desc" |
return | mixed |
static public insert ( string $table, mixed $input, boolean $ignore = false ) : mixed | ||
$table | string | The table name |
$input | mixed | Either a key/value array or a valid MySQL insert string |
$ignore | boolean | Set this to true to ignore duplicates |
return | mixed | The last inserted id if everything went fine or an error response. |
static public join ( string $table_1, string $table_2, string $on, mixed $select, mixed $where = null, string $order = null, integer $page = null, integer $limit = null, string $type = "JOIN" ) : mixed | ||
$table_1 | string | The table name of the first table |
$table_2 | string | The table name of the second table |
$on | string | The MySQL ON clause without the ON keyword. ie: "user_id = comment_user" |
$select | mixed | Either an array of fields or a MySQL string of fields |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
$order | string | Order clause without the order keyword. ie: "added desc" |
$page | integer | a page number |
$limit | integer | a number for rows to return |
$type | string | The join type (JOIN, LEFT, RIGHT, INNER) |
return | mixed |
static public left_join ( string $table_1, string $table_2, string $on, mixed $select, mixed $where = null, string $order = null, integer $page = null, integer $limit = null ) : mixed | ||
$table_1 | string | The table name of the first table |
$table_2 | string | The table name of the second table |
$on | string | The MySQL ON clause without the ON keyword. ie: "user_id = comment_user" |
$select | mixed | Either an array of fields or a MySQL string of fields |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
$order | string | Order clause without the order keyword. ie: "added desc" |
$page | integer | a page number |
$limit | integer | a number for rows to return |
return | mixed |
static public row ( string $table, mixed $select = '*', mixed $where = null, string $order = null ) : mixed | ||
$table | string | The table name |
$select | mixed | Either an array of fields or a MySQL string of fields |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
$order | string | Order clause without the order keyword. ie: "added desc" |
return | mixed |
static public select ( string $table, mixed $select = '*', mixed $where = null, string $order = null, integer $page = null, integer $limit = null, boolean $fetch = true ) : mixed | ||
$table | string | The table name |
$select | mixed | Either an array of fields or a MySQL string of fields |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
$order | string | Order clause without the order keyword. ie: "added desc" |
$page | integer | a page number |
$limit | integer | a number for rows to return |
$fetch | boolean | true: apply db::fetch(), false: don't apply db::fetch() |
return | mixed |
static public select_clause ( $fields ) : string | ||
return | string | The MySQL string |
static public simple_fields ( array $array ) : array | ||
$array | array | The result array |
return | array | The result array without those damn prefixes. |
static public update ( string $table, mixed $input, mixed $where ) : mixed | ||
$table | string | The table name |
$input | mixed | Either a key/value array or a valid MySQL insert string |
$where | mixed | Either a key/value array as AND connected where clause or a simple MySQL where clause string |
return | mixed | The number of affected rows or an error response |