I've added custom plugin (created by me) in WP in that plugin I have Class named BaseModel, which extends wpdb.
The problem here is everytime when I try to run query I get false or null or empty array as result.
class BaseModel extends wpdb{
public function __construct(){
parent::__construct(DB_HOST, DB_USER, DB_PASS, DB_NAME);
}
function get_destinations($limit, $order){
$query = "SELECT * FROM wp_relations";
$result = $this->get_results($query, ARRAY_A);
var_dump($result);
}
function get_total_destinations(){
}}
Can some one tell me what is wrong?
Thanks.
Actually it is not a full OOP solution but I solve this by adding global $wpdb into my functions.
class BaseModel {
function get_destinations($limit, $order){
global $wpdb;
$query = "SELECT * FROM wp_relations";
$result = $wpdb->get_results($query, ARRAY_A);
var_dump($result);
}
function get_total_destinations(){
}}
I hope you will find this helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With