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

	class Mod_images extends CI_Model
	{
		var $table = "tblimages";
		function __construct()
		{
			parent::__construct();
		}	
		
		function getimages ()
		{
			$this->db->SELECT("*");
			$this->db->from("tblimages");
			$this->db->join("tbluser","tbluser.userid = tblimages.upload_by","left");
			$this->db->join("tblcar","tblcar.id = tblimages.car_id","left");
			return $this->db->get();
			
			
		}
			
		function add($data)
		{
			$this->db->insert($this->table,$data);
			
		}
		
		function update($data,$id)
		{
			$this->db->where("img_id",$id);
			$this->db->update($this->table,$data);
		}
		
		function getById($id)
		{
			$this->db->where("img_id",$id);
			$q = $this->db->get($this->table);
			if($q->num_rows() > 0)
			{
				return $q->row();
			}
			return false;
		}
		
		function delete($id)
		{
			$this->db->where("img_id",$id);
			$this->db->delete($this->table);
		}	
		
		
	}