Class BPDB

Description

Located in /includes/class.bpdb.php (line 38)


	
			
Direct descendents
Class Description
BPDB_Multi
Variable Summary
Method Summary
void __construct ()
unknown BPDB ()
bool __destruct ()
false|void bail (string $message)
WP_Error check_database_version ([ $dbh_or_table = false])
resource &db_connect ([string $query = ''])
void|bool db_connect_host (array $args)
false|string db_version ([false|string|resource $dbh_or_table = false])
string escape (string|array $data)
void escape_by_ref ( &$string, string $s)
void escape_deep (array $array)
void flush ()
string get_caller ()
array get_col ([string|null $query = null], [int $x = 0])
mixed get_col_info ([string $info_type = 'name'], [int $col_offset = -1])
void get_error ([string $str = ''])
mixed get_results ([string $query = null], [string $output = OBJECT])
mixed get_row ([string|null $query = null], [string $output = OBJECT], [int $y = 0])
string get_var ([string|null $query = null], [int $x = 0], [int $y = 0])
bool has_cap (string $db_cap, [false|string|resource $dbh_or_table = false])
bool hide_errors ()
int|false insert (string $table, array $data, [array|string $format = null])
null|string prepare ([string $query = null], array|mixed $args, mixed $args,...)
bool print_error ([string $str = ''])
int|false query (string $query, [ $use_current = false])
bool select (string $db,  &$dbh)
string set_prefix (string $prefix, [false|array $tables = false])
bool show_errors ([bool $show = true])
bool suppress_errors ([bool $suppress = true])
true timer_start ()
int timer_stop ()
int|false update (string $table, array $data, array $where, [array|string $format = null], [ $where_format = null], array|string $format_where)
void _escape ( $data)
array _init (array $args)
void _real_escape ( $string)
void _weak_escape ( $string)
Variables
string $last_error = '' (line 64)

The last error during query.

  • since: 1.0
bool $real_escape = false (line 158)

Whether to use mysql_real_escape_string

  • since: 1.0
  • access: public
Methods
Constructor __construct (line 183)

PHP5 style constructor

Grabs the arguments, calls bpdb::_init() and then connects to the database

  • since: 1.0
void __construct ()

Redefined in descendants as:
Constructor BPDB (line 167)

PHP4 style constructor

  • return: Returns the result of bpdb::__construct()
  • since: 1.0
unknown BPDB ()
Destructor __destruct (line 247)

PHP5 style destructor, registered as shutdown function in PHP4

  • return: Always returns true
  • since: 1.0
bool __destruct ()
bail (line 1031)

Wraps errors in a nice header and footer and dies.

Will not die if bpdb::$show_errors is true

  • since: 1.0
false|void bail (string $message)
  • string $message
check_database_version (line 1050)

Whether or not MySQL database is at least the required minimum version.

  • since: 1.0
WP_Error check_database_version ([ $dbh_or_table = false])
  • $dbh_or_table
db_connect (line 260)

Figure out which database server should handle the query, and connect to it.

  • return: mysql database connection
  • since: 1.0
resource &db_connect ([string $query = ''])
  • string $query: query

Redefined in descendants as:
db_connect_host (line 283)

Connects to the database server and selects a database

  • return: void if cannot connect, false if cannot select, true if success
  • since: 1.0
void|bool db_connect_host (array $args)
  • array $args: args name => string DB name (required) user => string DB user (optional: false) password => string DB user password (optional: false) host => string DB hostname (optional: 'localhost') charset => string DB default charset. Used in a SET NAMES query. (optional) collate => string DB default collation. If charset supplied, optionally added to the SET NAMES query (optional)
db_version (line 1113)

The database version number

  • return: false on failure, version number on success
  • since: 1.0
false|string db_version ([false|string|resource $dbh_or_table = false])
  • false|string|resource $dbh_or_table: Which database to test. False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource.
escape (line 425)

Escapes content for insertion into the database using addslashes(), for security

  • return: query safe string
  • since: 1.0
string escape (string|array $data)
  • string|array $data
escape_by_ref (line 449)

Escapes content by reference for insertion into the database, for security

  • since: 1.0
void escape_by_ref ( &$string, string $s)
  • string $s
  • &$string
escape_deep (line 458)

Escapes array recursively for insertion into the database, for security

void escape_deep (array $array)
  • array $array
flush (line 624)

Kill cached query results.

  • since: 1.0
void flush ()
get_caller (line 1139)

Retrieve the name of the function that called bpdb.

Requires PHP 4.3 and searches up the list of functions until it reaches the one that would most logically had called this method.

  • return: The name of the calling function
  • since: 1.0
string get_caller ()
get_col (line 895)

Retrieve one column from the database.

Executes a SQL query and returns the column from the SQL result. If the SQL result contains more than one column, this function returns the column specified. If $query is null, this function returns the specified column from the previous SQL result.

  • return: Database query result. Array indexed from 0 by SQL result row number.
  • since: 1.0
array get_col ([string|null $query = null], [int $x = 0])
  • string|null $query: SQL query. If null, use the result from the previous query.
  • int $x: Column to return. Indexed from 0.
get_col_info (line 974)

Retrieve column metadata from the last query.

  • return: Column Results
  • since: 1.0
mixed get_col_info ([string $info_type = 'name'], [int $col_offset = -1])
  • string $info_type: one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill
  • int $col_offset: 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type
get_error (line 511)

Get SQL/DB error

  • since: 1.0
void get_error ([string $str = ''])
  • string $str: Error string
get_results (line 920)

Retrieve an entire SQL result set from the database (i.e., many rows)

Executes a SQL query and returns the entire SQL result.

  • return: Database query results
  • since: 1.0
mixed get_results ([string $query = null], [string $output = OBJECT])
  • string $query: SQL query.
  • string $output: (optional) ane of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K | ARRAY_K constants. With one of the first three, return an array of rows indexed from 0 by SQL result row number. Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively. With OBJECT_K and ARRAY_K, return an associative array of row objects keyed by the value of each row's first column's value. Duplicate keys are discarded.
get_row (line 858)

Retrieve one row from the database.

Executes a SQL query and returns the row from the SQL result.

  • return: Database query result in format specifed by $output
  • since: 1.0
mixed get_row ([string|null $query = null], [string $output = OBJECT], [int $y = 0])
  • string|null $query: SQL query.
  • string $output: (optional) one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...), a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively.
  • int $y: (optional) Row to return. Indexed from 0.
get_var (line 830)

Retrieve one variable from the database.

Executes a SQL query and returns the value from the SQL result. If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified. If $query is null, this function returns the value in the specified column and row from the previous SQL result.

  • return: Database query result
  • since: 1.0
string get_var ([string|null $query = null], [int $x = 0], [int $y = 0])
  • string|null $query: SQL query. If null, use the result from the previous query.
  • int $x: (optional) Column of value to return. Indexed from 0.
  • int $y: (optional) Row of value to return. Indexed from 0.
has_cap (line 1081)

Generic function to determine if a database supports a particular feature

  • since: 1.0
bool has_cap (string $db_cap, [false|string|resource $dbh_or_table = false])
  • string $db_cap: the feature
  • false|string|resource $dbh_or_table: Which database to test. False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource.
hide_errors (line 599)

Disables showing of database errors.

  • return: Whether showing of errors was active or not
  • since: 1.0
bool hide_errors ()
insert (line 735)

Insert a row into a table.

  1.  wpdb::insert'table'array'column' => 'foo''field' => 1337 )array'%s''%d' ) )

  • return: The number of rows inserted, or false on error.
  • see: bpdb::prepare()
  • since: 1.0
int|false insert (string $table, array $data, [array|string $format = null])
  • string $table: table name
  • array $data: Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
  • array|string $format: (optional) An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings.
prepare (line 486)

Prepares a SQL query for safe execution. Uses sprintf()-like syntax.

This function only supports a small subset of the sprintf syntax; it only supports %d (decimal number), %s (string). Does not support sign, padding, alignment, width or precision specifiers. Does not support argument numbering/swapping.

May be called like sprintf() or like vsprintf().

Both %d and %s should be left unquoted in the query string.

  1.  wpdb::prepare"SELECT * FROM `table` WHERE `column` = %s AND `field` = %d""foo"1337 )

null|string prepare ([string $query = null], array|mixed $args, mixed $args,...)
  • string $query: Query statement with sprintf()-like placeholders
  • array|mixed $args: The array of variables to substitute into the query's placeholders if being called like vsprintf(), or the first variable to substitute into the query's placeholders if being called like sprintf().
  • mixed $args,...: further variables to substitute into the query's placeholders if being called like sprintf().
print_error (line 539)

Print SQL/DB error.

  • return: False if the showing of errors is disabled.
  • since: 1.0
bool print_error ([string $str = ''])
  • string $str: The error to display
query (line 643)

Perform a MySQL database query, using current database connection.

More information can be found on the codex page.

  • return: Number of rows affected/selected or false on error
  • since: 1.0
int|false query (string $query, [ $use_current = false])
  • string $query
  • $use_current
select (line 375)

Selects a database using the current database connection.

The database name will be changed based on the current database connection. On failure, the execution will bail and display an DB error.

  • return: True on success, false on failure.
  • since: 1.0
bool select (string $db,  &$dbh)
  • string $db: MySQL database name
  • &$dbh
set_prefix (line 333)

Sets the table prefix for the WordPress tables.

  • return: the previous prefix (mostly only meaningful if all $table parameter was false)
  • since: 1.0
string set_prefix (string $prefix, [false|array $tables = false])
  • string $prefix: prefix
  • false|array $tables: tables (optional: false) table identifiers are array keys array values empty: set prefix: array( 'posts' => false, 'users' => false, ... ) string: set to that array value: array( 'posts' => 'my_posts', 'users' => 'my_users' ) OR array values (with numeric keys): array( 'posts', 'users', ... )

Redefined in descendants as:
show_errors (line 585)

Enables showing of database errors.

This function should be used only to enable showing of errors. bpdb::hide_errors() should be used instead for hiding of errors. However, this function can be used to enable and disable showing of database errors.

  • return: Old value for showing errors.
  • since: 1.0
bool show_errors ([bool $show = true])
  • bool $show: Whether to show or hide errors
supports_collation (line 1067)

Whether of not the database supports collation.

Called when BackPress is generating the table scheme.

  • return: True if collation is supported, false if version does not
  • since: 1.0
bool supports_collation ()
suppress_errors (line 612)

Whether to suppress database errors.

  • return: previous setting
  • since: 1.0
bool suppress_errors ([bool $suppress = true])
  • bool $suppress
timer_start (line 997)

Starts the timer, for debugging purposes.

  • since: 1.0
true timer_start ()
timer_stop (line 1012)

Stops the debugging timer.

  • return: Total time spent on the query, in milliseconds
  • since: 1.0
int timer_stop ()
update (line 774)

Update a row in the table

  1.  wpdb::update'table'array'column' => 'foo''field' => 1337 )array'ID' => )array'%s''%d' )array'%d' ) )

  • return: The number of rows updated, or false on error.
  • see: bpdb::prepare()
  • since: 1.0
int|false update (string $table, array $data, array $where, [array|string $format = null], [ $where_format = null], array|string $format_where)
  • string $table: table name
  • array $data: Data to update (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
  • array $where: A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw".
  • array|string $format: (optional) An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings.
  • array|string $format_where: (optional) An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $where will be treated as strings.
  • $where_format
_escape (line 400)
void _escape ( $data)
  • $data
_init (line 199)

Initialises the class variables based on provided arguments

  • return: The current connection settings after processing by init
  • since: 1.0
array _init (array $args)
  • array $args: The provided connection settings
_real_escape (line 391)
void _real_escape ( $string)
  • $string
_weak_escape (line 386)
void _weak_escape ( $string)
  • $string

Documentation generated on Fri, 18 May 2012 01:33:43 +0100 by phpDocumentor 1.4.3