<?php defined('ABSPATH') or die('No script kiddies please!!');
if ( !class_exists('EGPR_MODEL') ) {
    class EGPR_MODEL {
        var $egpr_wpdb;
        /**
         * Assigns global $wpdb to egpr_wpdb
         *
         * @global object $wpdb
         *
         * @since 1.0.0
         */
        function __construct() {
            global $wpdb;
            $this->egpr_wpdb = $wpdb;
        }
        
        
        /**
         * Fetches specific and all reviews
         *
         * @return array $gpr_results
         *
         * @since 1.0.0
         */
        function get_all_reviews($post_type) {
           $gpr_results = array();
           $gpr_results = $this->egpr_wpdb->get_results( $this->egpr_wpdb->prepare( "SELECT ID, post_title FROM {$this->egpr_wpdb->posts} WHERE post_type = %s and post_status = 'publish'", $post_type ), ARRAY_A );
           return $gpr_results;
        }
        
          /**
         * Fetches specific and all reviews
         *
         * @return array $gpr_results
         *
         * @since 1.0.0
         */
        function get_all_options_data($option_key) {
           $results = array();
           $results = get_option('egp_reviews');
           return $results;
        }
        
         /*
         * Get Review Data from table. 
         */
           function get_page_base_floating_review_id($post_id){
                $freviewid = get_post_meta( $post_id, 'egpr-floating-review', true);
                return $freviewid;
           }



    }
    $GLOBALS[ 'egpr_wpdb' ] = new EGPR_MODEL;
}