WordPressThe $wpdb Object


Remarks

There are two ways to reference the $wpdb object. The first is to use the PHP keyword global in order to act on the global instance of the object.

global $wpdb;
echo $wpdb->prefix;
// Outputs the prefix for the database

The second way to use the $wpdb object is to reference PHP's $GLOBALS super global variable.

echo $GLOBALS['wpdb']->prefix;
// This will also output the prefix for the database

The second way is discouraged as it may not be considered the best practice.