wppaste
WordPress

wpdb

Since
0.71
Source
wp-includes/class-wpdb.php:54
WordPress database access abstraction class.

Description

This class is used to interact with a database without needing to use raw SQL statements.
By default, WordPress uses this class to instantiate the global $wpdb object, providing access to the WordPress database.

It is possible to replace the global instance with your own by setting the $wpdb global variable in wp-content/db.php file to your class. The wpdb class will still be included, so you can extend it or simply use your own.

Compatibility

WordPress
since 0.71
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 5

Every hook that fires from inside wpdb, in the order it appears in the class, grouped by the method that fires it.

Properties · 62

$show_errorsboolpublic
Whether to show SQL/DB errors.
$suppress_errorsboolpublic
Whether to suppress errors during the DB bootstrapping. Default false.
$last_errorstringpublic
The error encountered during the last query.
$num_queriesintpublic
The number of queries made.
$num_rowsintpublic
Count of rows returned by the last query.
$rows_affectedintpublic
Count of rows affected by the last query.
$insert_idintpublic
The ID generated for an AUTO_INCREMENT column by the last query (usually INSERT).
$last_querystringpublic
The last query made.
$last_resultstdClass[]|nullpublic
Results of the last query.
$resultmysqli_result|bool|nullprotected
Database query result.
$col_metaarrayprotected
Cached column info, for confidence checking data before inserting.
$table_charsetstring[]protected
Calculated character sets keyed by table name.
$check_current_queryboolprotected
Whether text fields in the current query need to be confidence checked.
$checking_collationboolprivate
Flag to ensure we don't run into recursion problems when checking the collation.
$col_infoarrayprotected
Saved info on the table column.
$queriesarray[]public
Log of queries that were executed, for debugging purposes.
$reconnect_retriesintprotected
The number of times to retry reconnecting before dying. Default 5.
$prefixstringpublic
WordPress table prefix.
$base_prefixstringpublic
WordPress base table prefix.
$readyboolpublic
Whether the database queries are ready to start executing.
$blogidintpublic
Blog ID.
$siteidintpublic
Site ID.
$tablesstring[]public
List of WordPress per-site tables.
$old_tablesstring[]public
List of deprecated WordPress tables.
$global_tablesstring[]public
List of WordPress global tables.
$ms_global_tablesstring[]public
List of Multisite global tables.
$old_ms_global_tablesstring[]public
List of deprecated WordPress Multisite global tables.
$commentsstringpublic
WordPress Comments table.
$commentmetastringpublic
WordPress Comment Metadata table.
$optionsstringpublic
WordPress Options table.
$postmetastringpublic
WordPress Post Metadata table.
$postsstringpublic
WordPress Posts table.
$termsstringpublic
WordPress Terms table.
$term_relationshipsstringpublic
WordPress Term Relationships table.
$term_taxonomystringpublic
WordPress Term Taxonomy table.
$termmetastringpublic
WordPress Term Meta table.
$usermetastringpublic
WordPress User Metadata table.
$usersstringpublic
WordPress Users table.
$blogsstring|nullpublic
Multisite Blogs table.
$blogmetastring|nullpublic
Multisite Blog Metadata table.
$registration_logstring|nullpublic
Multisite Registration Log table.
$signupsstring|nullpublic
Multisite Signups table.
$sitestring|nullpublic
Multisite Sites table.
$sitecategoriesstring|nullpublic
Multisite Sitewide Terms table.
$sitemetastring|nullpublic
Multisite Site Metadata table.
$field_typesarraypublic
Format specifiers for DB columns.
$charsetstringpublic
Database table columns charset.
$collatestringpublic
Database table columns collate.
$dbuserstringprotected
Database Username.
$dbpasswordstringprotected
Database Password.
$dbnamestringprotected
Database Name.
$dbhoststringprotected
Database Host.
$dbhmysqli|false|nullprotected
Database handle.
$func_callstringpublic
A textual description of the last query/get_row/get_var call.
$is_mysqlboolpublic
Whether MySQL is used as the database engine.
$incompatible_modesstring[]protected
A list of incompatible SQL modes.
$allow_unsafe_unquoted_parametersboolprivate
Backward compatibility, where wpdb::prepare() has not quoted formatted/argnum placeholders.
$use_mysqliboolprivate
Whether to use the mysqli extension over mysql. This is no longer used as the mysql extension is no longer supported.
$has_connectedboolprivate
Whether we've managed to successfully connect at some point.
$time_startfloatpublic
Time when the last query was performed.
$errorWP_Error|stringpublic
The last SQL error that was encountered.

Methods · 72

Source code

#[AllowDynamicProperties]class wpdb { 	/**	 * Whether to show SQL/DB errors.	 *	 * Default is to show errors if both WP_DEBUG and WP_DEBUG_DISPLAY evaluate to true.	 *	 * @since 0.71	 *	 * @var bool	 */	public $show_errors = false; 	/**	 * Whether to suppress errors during the DB bootstrapping. Default false.	 *	 * @since 2.5.0	 *	 * @var bool	 */	public $suppress_errors = false; 	/**	 * The error encountered during the last query.	 *	 * @since 2.5.0	 *	 * @var string	 */	public $last_error = ''; 	/**	 * The number of queries made.	 *	 * @since 1.2.0	 *	 * @var int	 */	public $num_queries = 0; 	/**	 * Count of rows returned by the last query.	 *	 * @since 0.71	 *	 * @var int	 */	public $num_rows = 0; 	/**	 * Count of rows affected by the last query.	 *	 * @since 0.71	 *	 * @var int	 */	public $rows_affected = 0; 	/**	 * The ID generated for an AUTO_INCREMENT column by the last query (usually INSERT).	 *	 * @since 0.71	 *	 * @var int	 */	public $insert_id = 0; 	/**	 * The last query made.	 *	 * @since 0.71	 *	 * @var string	 */	public $last_query; 	/**	 * Results of the last query.	 *

Changelog

Introduced in 0.71. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wpdb.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.