<?php

class AdminModel extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}


	public function record_count($param){

		$data = [];
		$where = '';
		if (isset($param['name']) && $param['name'] != '') {
			$where .= " AND  fullname like '%".$param['name'].
			"%' ";
		}
		if (isset($param['email']) && $param['email'] != '') {
			$where .= " AND  email like '%".$param['email'].
			"%' ";
		}

		$sql = "SELECT COUNT( DISTINCT admin_id ) AS TotalrecordCount FROM  `admin`  WHERE 1 $where";

		$recordSet = $this->db->query($sql);
		if ($recordSet) {
			$row = $recordSet->row();
			$total_rows = $row->TotalrecordCount;
		}

		return $total_rows;

	}

	public function all_data_list($limit,$start,$param){

		$data=[];
		$where = '';
		if (isset($param['name']) && $param['name'] != '') {
			$where .= " AND  fullname like '%".$param['name'].
			"%' ";
		}
		if (isset($param['email']) && $param['email'] != '') {
			$where .= " AND  email like '%".$param['email'].
			"%' ";
		}

		$sql="SELECT * FROM `admin` WHERE 1  $where  LIMIT ".$start.",".$limit ;
        $data = $this->db->query($sql)->result_array();
        // echo "<pre>";print_r($data);exit();
		return $data;
	}

}

?>
