static void format_query(
string
$sql, [boolean
$html = true]
)
|
|
Format a SQL query
Parameters:
|
string |
$sql: |
SQL |
|
boolean |
$html: |
Format with/for HTML? |
Information Tags:
| Todo: | dh> Steal the code from phpMyAdmin :) |
DB Constructor
Connects to the server and selects a database.
Parameters:
|
array |
$params: |
An array of parameters. Manadatory: - 'user': username to connect with
- 'password': password to connect with
OR Optional: - 'name': the name of the default database, see DB::select()
- 'host': host of the database; Default: 'localhost'
- 'show_errors': Display SQL errors? (true/false); Default: don't change member default ($show_errors)
- 'halt_on_error': Halt on error? (true/false); Default: don't change member default ($halt_on_error)
- 'table_options': sets $table_options
- 'use_transactions': sets $use_transactions
- 'aliases': Aliases for tables (array( alias => table name )); Default: no aliases.
- 'new_link': create a new link to the DB, even if there was a mysql_connect() with
the same params before. (requires PHP 4.2)
- 'client_flags': optional settings like compression or SSL encryption. See http://www.php.net/manual/en/ref.mysql.php#mysql.client-flags.
(requires PHP 4.3)
|
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 or a 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 debug_get_rows_table(
$max_lines, [
$break_at_comma = false]
)
|
|
Get a table (or "<p>No Results.</p>") for the SELECT query results.
Parameters:
|
|
$max_lines: |
|
|
|
$break_at_comma: |
|
API Tags:
| Return: | HTML table or "No Results" if the |
Displays all queries that have been executed
Format a string correctly for safe insert under all PHP conditions
Parameters:
Kill cached query results
array get_assoc(
[
$query = NULL], [
$title = '']
)
|
|
Function to get the second column from the cached result indexed by the first column
Parameters:
API Tags:
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:
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). |
Parameters:
API Tags:
| Return: | Return the given value or 'NULL', if it's === NULL. |
void print_error(
[string
$title = ''], [string
$html_str = ''], [string|false
$query_title = '']
)
|
|
Print SQL/DB error.
TODO: fp> bloated: it probably doesn't make sense to display errors if we don't stop. Any use case? dh> Sure. Local testing (and test cases).
Parameters:
|
string |
$title: |
Short error (no HTML) |
|
string |
$html_str: |
Extended description/help for the error (for HTML) |
|
string|false |
$query_title: |
Query title; false if DB::$last_query should not get displayed |
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 |
string quote(
string|array|null
$str
)
|
|
Quote a value, either in single quotes (and escaped) or if it's NULL as 'NULL'.
Parameters:
API Tags:
| Return: | Quoted (and escaped) value or 'NULL'. |
Rollback current transaction
Select a DB (if another one needs to be selected)
Parameters:
boolean set_connection_charset(
string
$charset, [boolean
$use_map = false]
)
|
|
Set the charset of the connection.
WARNING: this will fail on MySQL 3.23
Parameters:
|
string |
$charset: |
Charset |
|
boolean |
$use_map: |
Use the "regular charset => mysql charset map"? |
API Tags:
| Return: | true on success, false on failure |
| Staticvar: | array $mysql_charset_map: "regular charset => mysql charset map" |
void week(
string
$date, integer
$startofweek
)
|
|
Returns the correct WEEK() function to get the week number for the given date.
Parameters:
|
string |
$date: |
will be used as is |
|
integer |
$startofweek: |
0 for sunday, 1 for monday |
Information Tags: