<?php defined('BASEPATH') or exit('No direct Access is Allowed'); ?>
<?php
class Presentermodel extends CI_Model{

	public function __construct() {
        parent::__construct();
    }
	public function presenter_list($limit, $offset){

		$offset = ($offset-1)*$limit;
		$query=$this->db->select(['master_user.*'])
		->from('master_user')
		// ->join('mu_teacher_basic','mu_teacher_basic.user_id=master_user.id','right')
		// ->join('mu_teacher_extra_info','mu_teacher_extra_info.user_id=master_user.id','right')
		// ->join('mu_teacher_pf_class','mu_teacher_pf_class.user_id=master_user.id','right')
		// ->join('mu_teacher_qualfication','mu_teacher_qualfication.user_id=master_user.id','right')
		// ->group_by('mu_teacher_basic.user_id')
		// ->group_by('mu_teacher_extra_info.user_id')
		// ->group_by('mu_teacher_pf_class.user_id')
		// ->group_by('mu_teacher_qualfication.user_id')
		->where('category','1')

    ->limit($limit, $offset)
		->get();
		//echo $this->db->last_query();die;
		return $query->result();
	}

	public function num_rows(){
        $this->db->simple_query('SET sql_mode=(SELECT REPLACE(@@sql_mode,"ONLY_FULL_GROUP_BY",""))');
				  $query=$this->db->select(['master_user.*'])
	    //$query=$this->db->select(['master_user.*','mu_teacher_basic.upload_resume','mu_teacher_basic.screenshot_speed'])
		->from('master_user')
		//->join('mu_teacher_basic','mu_teacher_basic.user_id=master_user.id','right')
		//->join('mu_teacher_extra_info','mu_teacher_extra_info.user_id=master_user.id','right')
	//	->join('mu_teacher_pf_class','mu_teacher_pf_class.user_id=master_user.id','right')
	//	->join('mu_teacher_qualfication','mu_teacher_qualfication.user_id=master_user.id','right')
	///	->group_by('mu_teacher_basic.user_id')
	//	->group_by('mu_teacher_extra_info.user_id')
	//	->group_by('mu_teacher_pf_class.user_id')
	//	->group_by('mu_teacher_qualfication.user_id')
		->where('category','1')
		//->order_by("presenter", "asc")
		->get();
		return $query->num_rows();
	}
	public function insert_presenter($data_presenter){

		$this->db->insert('master_user', $data_presenter);
		$data_presenter['id'] = $this->db->insert_id();
    	return $data_presenter['id'];
	}

	public function update_presenter($data_presenter,$list_id){
	    $this->db->where('category','1');
		$this->db->where('id',$list_id);
		$this->db->update('master_user', $data_presenter);
		return true;
	}

	public function view_presenter($list_id){

	    $query=$this->db->select(['*'])->from('master_user')->where('category','1')->where('id',$list_id)->get();
		return $query->row();
	}

	public function delete_presenter($list_id){
	    $this->db->where('category','1');
		$this->db->where('id', $list_id);
		$this->db->delete('master_user');
	}
	public function count_presenter($email){
	    $query=$this->db->select(['email'])->from('master_user')->where('category','1')->where('email',$email)->get();
	    return $query->num_rows();
	}

}
?>
