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

	class Mod_Promotion extends CI_Model
	{
		function __construct()
		{
			parent::__construct();
		}
		
		private $table = 'tbl_promotions';	
		
		function getPromotion()
		{
			$this->db->SELECT("*");
			$this->db->from($this->table);
			$this->db->join("tbluser","tbluser.userid = tbl_promotions.createdby","left");		
			$this->db->order_by("tbl_promotions.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;
		}
		
	}