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

	class Mod_brand extends CI_Model
	{
		var $table = "tblbrand";
		function __construct()
		{
			parent::__construct();
		}	
		
		function getbrand ($b=1,$id="")
		{
			$this->db->SELECT("*");
			//$this->db->SELECT('csd_category.id AS cat_id');
			$this->db->from("tblbrand");
			$this->db->join("tbluser","tbluser.userid = tblbrand.createby","left");		
			$this->db->order_by("tblbrand.id", "DESC"); 
			
			return $this->db->get();
			
			
		}
		
		 
		function countAll()
		{
			return $this->db->count_all_results('tblbrand');
		}
		
			
		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;
		}
		
			
		
		
	}