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

	class Mod_drivers extends CI_Model
	{
		var $table = "tbldrivers";
		function __construct()
		{
			parent::__construct();
		}	
		
		function getdrivers ($b=1,$id="")
		{
			$this->db->SELECT("*, `tbldrivers`.`createdate` as `mydate`");
			$this->db->from("tbldrivers");
			$this->db->join("tbluser","tbluser.userid = tbldrivers.createby","left");		
			$this->db->order_by("tbldrivers.id", "DESC"); 
			return $this->db->get();
		}
		
		 
		function countAll()
		{
			return $this->db->count_all_results('tbldrivers');
		}
		
			
		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;
		}

	}