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

	class Mod_category extends CI_Model
	{
		var $table = "blog_cats";
		function __construct()
		{
			parent::__construct();
		}	
		
		
		function getcategory()
		{
			$this->db->SELECT("*");
			$this->db->from($this->table);
			$this->db->join("tbluser","tbluser.userid = blog_cats.createdby","left");		
			$this->db->order_by("blog_cats.catID", "DESC"); 
			return $this->db->get();
		}
		
			
		function add($data)
		{
			$this->db->insert($this->table,$data);
		}


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