WPDev.one
Core Class

wpdb

class wpdb // Constructor: function Object() { [native code] }

WordPress database access abstraction class.

Methods 72 methods

Method / Return Description
__construct()
void

Connects to the database server and selects a database.

Parameters: $dbuser: mixed, $dbpassword: mixed, $dbname: mixed, $dbhost: mixed
__get()
mixed

Makes private properties readable for backward compatibility.

Parameters: $name: mixed
__set()
void

Makes private properties settable for backward compatibility.

Parameters: $name: mixed, $value: mixed
__isset()
bool

Makes private properties check-able for backward compatibility.

Parameters: $name: mixed
__unset()
void

Makes private properties un-settable for backward compatibility.

Parameters: $name: mixed
init_charset()
void

Sets $this->charset and $this->collate.

determine_charset()
array

Determines the best charset and collation to use given a charset and collation.

Parameters: $charset: mixed, $collate: mixed
set_charset()
void

Sets the connection's character set.

Parameters: $dbh: mixed, $charset: mixed, $collate: mixed
set_sql_mode()
void

Changes the current SQL mode, and ensures its WordPress compatibility.

Parameters: $modes: mixed
set_prefix()
(string

Sets the table prefix for the WordPress tables.

Parameters: $prefix: mixed, $set_table_names: mixed
set_blog_id()
int

Sets blog ID.

Parameters: $blog_id: mixed, $network_id: mixed
get_blog_prefix()
string

Gets blog prefix.

Parameters: $blog_id: mixed
tables()
string[]

Returns an array of WordPress tables.

Parameters: $scope: mixed, $prefix: mixed, $blog_id: mixed
select()
void

Selects a database using the current or provided database connection.

Parameters: $db: mixed, $dbh: mixed
_weak_escape()
string

Do not use, deprecated.

Parameters: $data: mixed
_real_escape()
string

Real escape using mysqli_real_escape_string().

Parameters: $data: mixed
_escape()
(string

Escapes data. Works on arrays.

Parameters: $data: mixed
escape()
(string

Do not use, deprecated.

Parameters: $data: mixed
escape_by_ref()
void

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

Parameters: $data: mixed
quote_identifier()
string

Quotes an identifier for a MySQL database, e.g. table/field names.

Parameters: $identifier: mixed
_escape_identifier_value()
string

Escapes an identifier value without adding the surrounding quotes.

Parameters: $identifier: mixed
prepare()
(string

Prepares a SQL query for safe execution.

Parameters: $query: mixed, $args: mixed
esc_like()
string

First half of escaping for `LIKE` special characters `%` and `_` before preparing for SQL.

Parameters: $text: mixed
print_error()
(void

Prints SQL/DB error.

Parameters: $str: mixed
show_errors()
bool

Enables showing of database errors.

Parameters: $show: mixed
hide_errors()
bool

Disables showing of database errors.

suppress_errors()
bool

Enables or disables suppressing of database errors.

Parameters: $suppress: mixed
flush()
void

Kills cached query results.

db_connect()
bool

Connects to and selects database.

Parameters: $allow_bail: mixed
parse_db_host()
(array

Parses the DB_HOST setting to interpret it for mysqli_real_connect().

Parameters: $host: mixed
check_connection()
(bool

Checks that the connection to the database is still up. If not, try to reconnect.

Parameters: $allow_bail: mixed
query()
(int

Performs a database query, using current database connection.

Parameters: $query: mixed
_do_query()
void

Internal function to perform the mysqli_query() call.

Parameters: $query: mixed
log_query()
void

Logs query data.

Parameters: $query: mixed, $query_time: mixed, $query_callstack: mixed, $query_start: mixed, $query_data: mixed
placeholder_escape()
string

Generates and returns a placeholder escape string for use in queries returned by ::prepare().

add_placeholder_escape()
string

Adds a placeholder escape string, to escape anything that resembles a printf() placeholder.

Parameters: $query: mixed
remove_placeholder_escape()
string

Removes the placeholder escape strings from a query.

Parameters: $query: mixed
insert()
(int

Inserts a row into the table.

Parameters: $table: mixed, $data: mixed, $format: mixed
replace()
(int

Replaces a row in the table or inserts it if it does not exist, based on a PRIMARY KEY or a UNIQUE index.

Parameters: $table: mixed, $data: mixed, $format: mixed
_insert_replace_helper()
(int

Helper function for insert and replace.

Parameters: $table: mixed, $data: mixed, $format: mixed, $type: mixed
update()
(int

Updates a row in the table.

Parameters: $table: mixed, $data: mixed, $where: mixed, $format: mixed, $where_format: mixed
delete()
(int

Deletes a row in the table.

Parameters: $table: mixed, $where: mixed, $where_format: mixed
process_fields()
(array

Processes arrays of field/value pairs and field formats.

Parameters: $table: mixed, $data: mixed, $format: mixed
process_field_formats()
array

Prepares arrays of value/format pairs as passed to wpdb CRUD methods.

Parameters: $data: mixed, $format: mixed
process_field_charsets()
(array

Adds field charsets to field/value/format arrays generated by wpdb::process_field_formats().

Parameters: $data: mixed, $table: mixed
process_field_lengths()
(array

For string fields, records the maximum string length that field can safely save.

Parameters: $data: mixed, $table: mixed
get_var()
(string

Retrieves one value from the database.

Parameters: $query: mixed, $x: mixed, $y: mixed
get_row()
(array

Retrieves one row from the database.

Parameters: $query: mixed, $output: mixed, $y: mixed
get_col()
array

Retrieves one column from the database.

Parameters: $query: mixed, $x: mixed
get_results()
(array

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

Parameters: $query: mixed, $output: mixed
get_table_charset()
(string

Retrieves the character set for the given table.

Parameters: $table: mixed
get_col_charset()
(string

Retrieves the character set for the given column.

Parameters: $table: mixed, $column: mixed
get_col_length()
(array

Retrieves the maximum string length allowed in a given column.

Parameters: $table: mixed, $column: mixed
check_ascii()
bool

Checks if a string is ASCII.

Parameters: $input_string: mixed
check_safe_collation()
bool

Checks if the query is accessing a collation considered safe on the current version of MySQL.

Parameters: $query: mixed
strip_invalid_text()
(array

Strips any invalid characters based on value/charset pairs.

Parameters: $data: mixed
strip_invalid_text_from_query()
(string

Strips any invalid characters from the query.

Parameters: $query: mixed
strip_invalid_text_for_column()
(string

Strips any invalid characters from the string for a given table and column.

Parameters: $table: mixed, $column: mixed, $value: mixed
get_table_from_query()
(string

Finds the first table name referenced in a query.

Parameters: $query: mixed
load_col_info()
void

Loads the column metadata from the last query.

get_col_info()
mixed

Retrieves column metadata from the last query.

Parameters: $info_type: mixed, $col_offset: mixed
timer_start()
true

Starts the timer, for debugging purposes.

timer_stop()
float

Stops the debugging timer.

bail()
(void

Wraps errors in a nice header and footer and dies.

Parameters: $message: mixed, $error_code: mixed
close()
bool

Closes the current database connection.

check_database_version()
(void

Determines whether MySQL database is at least the required minimum version.

supports_collation()
bool

Determines whether the database supports collation.

get_charset_collate()
string

Retrieves the database character collate.

has_cap()
bool

Determines whether the database or WPDB supports a particular feature.

Parameters: $db_cap: mixed
get_caller()
string

Retrieves a comma-separated list of the names of the functions that called wpdb.

db_version()
(string

Retrieves the database server version.

db_server_info()
string

Returns the version of the MySQL server.

Properties

Property / Type Description
$show_errors
mixed
public
No description available.
$suppress_errors
mixed
public
No description available.
$last_error
mixed
public
No description available.
$num_queries
mixed
public
No description available.
$num_rows
mixed
public
No description available.
$rows_affected
mixed
public
No description available.
$insert_id
mixed
public
No description available.
$last_query
mixed
public
No description available.
$last_result
mixed
public
No description available.
$result
mixed
public
No description available.
$col_meta
mixed
public
No description available.
$table_charset
mixed
public
No description available.
$check_current_query
mixed
public
No description available.
$checking_collation
mixed
public
No description available.
$col_info
mixed
public
No description available.
$queries
mixed
public
No description available.
$reconnect_retries
mixed
public
No description available.
$prefix
mixed
public
No description available.
$base_prefix
mixed
public
No description available.
$ready
mixed
public
No description available.
$blogid
mixed
public
No description available.
$siteid
mixed
public
No description available.
$tables
mixed
public
No description available.
$old_tables
mixed
public
No description available.
$global_tables
mixed
public
No description available.
$ms_global_tables
mixed
public
No description available.
$old_ms_global_tables
mixed
public
No description available.
$comments
mixed
public
No description available.
$commentmeta
mixed
public
No description available.
$links
mixed
public
No description available.
$options
mixed
public
No description available.
$postmeta
mixed
public
No description available.
$posts
mixed
public
No description available.
$terms
mixed
public
No description available.
$term_relationships
mixed
public
No description available.
$term_taxonomy
mixed
public
No description available.
$termmeta
mixed
public
No description available.
$usermeta
mixed
public
No description available.
$users
mixed
public
No description available.
$blogs
mixed
public
No description available.
$blogmeta
mixed
public
No description available.
$registration_log
mixed
public
No description available.
$signups
mixed
public
No description available.
$site
mixed
public
No description available.
$sitecategories
mixed
public
No description available.
$sitemeta
mixed
public
No description available.
$field_types
mixed
public
No description available.
$charset
mixed
public
No description available.
$collate
mixed
public
No description available.
$dbuser
mixed
public
No description available.
$dbpassword
mixed
public
No description available.
$dbname
mixed
public
No description available.
$dbhost
mixed
public
No description available.
$dbh
mixed
public
No description available.
$func_call
mixed
public
No description available.
$is_mysql
mixed
public
No description available.
$incompatible_modes
mixed
public
No description available.
$allow_unsafe_unquoted_parameters
mixed
public
No description available.
$use_mysqli
mixed
public
No description available.
$has_connected
mixed
public
No description available.
$time_start
mixed
public
No description available.
$error
mixed
public
No description available.

Class Information

Since Version
0.71
Source File
wp-includes/class-wpdb.php
Advertisement