I am writing a wordpress plugin and seeking to request some data from the custom table during my database using:

$current_text = $wpdb->get_results("SELECT text FROM addtext ORDER BY id DESC LIMIT 1");

but simply obtain the error Undefined variable: wpdb

Any idea why this is not working? I have adopted the paperwork and searched Google, without any luck. Still pretty a new comer to Wordpress plug ins so most likely something apparent.


I desired to make use of global $wpdb; during my function.