DB DB(
$dbuser,
$dbpassword,
$dbname,
$dbhost,
$dbaliases, [
$halt_on_error = true], [
$db_use_transactions = false], [
$dbtableoptions = '']
)
|
|
DB Constructor
connects to the server and selects a database
blueyed> Note: Too many parameters (and without default). Should be accessed through members. $halt_on_error is relevant to the connect procedure and should be put after $dbhost.
Parameters:
|
|
$dbuser: |
|
|
|
$dbpassword: |
|
|
|
$dbname: |
|
|
|
$dbhost: |
|
|
|
$dbaliases: |
|
|
|
$halt_on_error: |
|
|
|
$db_use_transactions: |
|
|
|
$dbtableoptions: |
|
BEGIN A TRANSCATION
Note: By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk. Once you execute a BEGIN, the updates are "pending" until you execute a COMMIT {@see DB::commit()} or a ROLLBACK {@see DB:rollback()}
Note 2: standard syntax would be START TRANSACTION but it's not supported by older MySQL versions whereas BEGIN is...
Note 3: The default isolation level is REPEATABLE READ.
Commit current transaction
string compString(
mixed
$val
)
|
|
Returns the appropriate string to compare $val in a WHERE clause.
Parameters:
|
mixed |
$val: |
Value to create a "compare-String" for |
API Tags:
| Return: | Either 'IS NULL', 'IN ("a", "b", "c")' or " = 'a'". |
void debug_dump_rows(
$max_lines, [
$break_at_comma = false]
)
|
|
Displays the last query string that was sent to the database & a table listing results (if there were any).
(abstracted into a seperate file to save server overhead).
Parameters:
|
|
$max_lines: |
|
|
|
$break_at_comma: |
|
void dumpvar(
mixed
$mixed
)
|
|
Alias for vardump()
Parameters:
|
mixed |
$mixed: |
Variable to dump |
Displays all queries that have been exectuted
Format a string correctly for safe insert under all PHP conditions
Parameters:
Kill cached query results
array get_col(
[
$query = NULL], [
$x = 0], [
$title = '']
)
|
|
Function to get 1 column from the cached result set based in X index see docs for usage and info
Parameters:
void get_col_info(
[
$info_type = 'name'], [
$col_offset = -1]
)
|
|
Function to get column meta data info pertaining to the last query
see docs for more info and usage
Parameters:
string get_list(
[string|NULL
$query = NULL], [integer
$x = 0], [
$title = '']
)
|
|
Get a column as comma-seperated list.
Parameters:
|
string|NULL |
$query: |
Query to execute |
|
integer |
$x: |
Column of the result set |
|
|
$title: |
|
array get_results(
[
$query = NULL], [
$output = OBJECT], [
$title = '']
)
|
|
Return the the query as a result set - see docs for more details
Parameters:
array|object get_row(
[
$query = NULL], [
$output = OBJECT], [
$y = 0], [
$title = '']
)
|
|
Get one row from the DB - see docs for more detail
Parameters:
|
|
$query: |
|
|
|
$output: |
|
|
|
$y: |
|
|
|
$title: |
|
mixed get_var(
[
$query = NULL], [
$x = 0], [
$y = 0], [
$title = '']
)
|
|
Get one variable from the DB - see docs for more detail
Note: To be sure that you received NULL from the DB and not "no rows" check for $num_rows.
Parameters:
API Tags:
| Return: | NULL if not found, the value otherwise (which may also be NULL). |
void print_error(
[
$str = ''], [
$query_title = '']
)
|
|
Print SQL/DB error.
Parameters:
mixed query(
string
$query, [string
$title = '']
)
|
|
Basic Query
Parameters:
|
string |
$query: |
SQL query |
|
string |
$title: |
title for debugging |
API Tags:
| Return: | # of rows affected or false if error |
Information Tags:
| Todo: | implement transactions! |
Select a DB (if another one needs to be selected)
Parameters:
void vardump(
[mixed
$mixed = '']
)
|
|
Dumps the contents of any input variable to screen in a nicely formatted and easy to understand way - any type: Object, Var or Array
Parameters:
|
mixed |
$mixed: |
Variable to dump |
void week(
string
$date, integer
$startofweek
)
|
|
Returns the correct WEEK() function to get the week number for the given date.
{@see http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html}
Parameters:
|
string |
$date: |
will be used as is |
|
integer |
$startofweek: |
0 for sunday, 1 for monday |
Information Tags:
| Todo: | disable when MySQL < 4 |