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

	class Mod_promotioncode extends CI_Model
	{
		function __construct()
		{
			parent::__construct();
		}
		
		private $table = 'tblcoupon';	
		
		function getpromotioncode()
		{
			$this->db->SELECT("*");
			$this->db->from($this->table);
			$this->db->join("tbluser","tbluser.userid = tblcoupon.createdby","left");		
			$this->db->order_by("tblcoupon.id", "DESC"); 
			return $this->db->get();
		}
			
		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);
			$this->db->from($this->table);
			$q = $this->db->get();
			if($q->num_rows() > 0)
			{
				return $q->row();
			}
			return false;
		}
		
	}