$wpdb in new OOP plugin

Hi I'm trying to write my first Wordpress plugin. I'm using classes to make it easier to maintain.

I'm wondering how I can use the WPDB class in my wordpress plugin.

Answers


$wpdb is a global variable, which is an instantiation of the class already set up to talk to the WordPress database.

you can use it in this manner -

global $wpdb;
$result = $wpdb->get_row( "SELECT value FROM ".$wpdb->prefix."plg_table" );
echo $result;

For more info you can also check this link - Link To CODEX

If its your first i prefer to modify the existing one that i suggested few days back, check this link as it may help you showing plugin in frontend of website or in page


Need Your Help

Is LDAP included in MFP CLI?

ldap ibm-mobilefirst

I have a little question w.r.t MFP Client

How to integrate a browserified node module into brunch-built app?

javascript backbone.js browserify brunch

New with front end dev, i'm trying to build a backbone based webapp with brunch.