<?php
class pationt_model extends CI_Model {
	public function add_pationt($data){
		$this->db->insert('bimaran', $data);
	}
	public function update_pationt($id,$data){
		$this->db->where("id",$id);
		$this->db->update('bimaran',$data);
	}
	public function list_pationt($uid,$limit=-1,$offset=-1,$search="null"){
		$this->db->where("uid",$uid);
		if($limit != -1 && $offset !=-1){
			$this->db->limit($limit,$offset);
		}
		if($search!="null"){
			$this->db->like('full_name',$search);
		}
		$this->db->order_by("id", "desc");
		$result = $this->db->get('bimaran');
        return $result->result();
	}
	public function count_pationt($uid){
		$this->db->where("uid",$uid);
		$result = $this->db->get('bimaran');
        return count($result->result());
	}
	public function delete_pationt($id){
		 $this->db->where('id', $id);
  $this->db->delete('bimaran');
	}
	public function get_pationt($uid,$id){
		$this->db->where("uid",$uid);
		$this->db->where("id",$id);
		
		$result = $this->db->get('bimaran');
        return $result->result();
	}
	public function get_pationt_byname($name){
		$this->db->where("full_name",$name);
		$result = $this->db->get('bimaran');
		return $result->result();
	}
	function getLastInserted() {
$query = $this->db->query("SELECT *
  FROM bimaran
 ORDER
    BY Id DESC
 LIMIT 1");
$query = $query->result();
return $query[0]->id;
       }
	
}
?>