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

	class Mod_component extends CI_Model
	{
		var $table = "tblcomponent";
		function __construct()
		{
			parent::__construct();
		}	
		
		function getcomponent ($b=1,$id="")
		{
			$this->db->SELECT("*");
			$this->db->SELECT('tblcomponent.status AS component_status');
			$this->db->SELECT('tblcomponent.id AS component_id');
			$this->db->SELECT('tblcomponent.createdate AS componentdate');
			$this->db->from("tblcomponent");
			$this->db->join("tbluser","tbluser.userid = tblcomponent.createby","left");			
			$this->db->join("tblcar","tblcar.id = tblcomponent.car_id","left");		
			$this->db->order_by("tblcomponent.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;
		}
		
		
	}