<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Mod_location extends CI_Model
	{
		var $table = "tbllocation";
		function __construct()
		{
			parent::__construct();
		}	
		
		function getlocation()
		{
			$this->db->SELECT("*");
			//$this->db->SELECT('csd_category.id AS cat_id');
			$this->db->from("tbllocation");
			$this->db->join("tbluser","tbluser.userid = tbllocation.createby","left");		
			$this->db->order_by("tbllocation.id", "DESC"); 			
			return $this->db->get();
		}
		
		 
		function countAll()
		{
			return $this->db->count_all_results('tbllocation');
		}
		
			
		function add($data)
		{
			$this->db->insert($this->table,$data);
			
		}


		function update($data,$id)
		{
			$this->db->where("id",$id);
			$this->db->update($this->table,$data);
		}
		

		function delete($id)
		{
			$this->db->where("id",$id);
			$this->db->delete($this->table);
		}
		
	
		function getById($id)
		{
			$this->db->where("id",$id);
			$q = $this->db->get($this->table);
			if($q->num_rows() > 0)
			{
				return $q->row();
			}
			return false;
		}
		
			
		
		
	}