Table of Contents
Using the $wpdb global object
WordPress provides a global object, $wpdb, which is an instantiation of the wpdb class. By default, $wpdb is instantiated to talk to the WordPress database.
The recommended way to access $wpdb in your WordPress PHP code is to declare $wpdb as a global variable using the global keyword, like this:
global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1", OBJECT );
Alternatively, if the above doesn’t suit your needs for whatever reason, use the superglobal $GLOBALS in the following manner:
$results = $GLOBALS['wpdb']->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1", OBJECT );
Latest WordPress Products #
-

MegaStore – High-Converting WooCommerce Theme #
BestsellersFeaturedFrom: $59 -

Organici – Fresh Food & Grocery Store – WooCommerce Multi-Purpose Theme #
FeaturedHot & NewFrom: $39



