<?php
class Keyword_model
  extends CI_Model {
	
	public function __construct()
	{
		$this->load->database();	
	}

	public function create_keyword($keywords)
	{
		$query = $this->db->insert('keywords', $keywords);
		$query = $this->db->get_where('keywords', array('id' => $this->db->insert_id()));
		if ($query->num_rows() == 0) {
			return false;
		} else {
			return $query->row();
		}
	}
	
		public function delete_campaign($slug)
	{
		$this->db->delete('keywords', array('id' => $slug )); 
		 
	}
	
		public function update_campaign($c_slug, $data)
	{
		$this->db->where('id', $c_slug);
		$this->db->update('keywords', $data);		
	}
	
	public function get_campaign_one($c_slug)
	{
	    
		$query = $this->db->get('keywords');
		$query = $this->db->get_where('keywords',array('id'=>$c_slug) );
		if ($query->num_rows() == 0) {
			return false;
		} else {
			return $query->row();
		}
	}
	
		public function get_campaign_one_hash($c)
	{
	    
		$query = $this->db->get('keywords');
		$query = $this->db->get_where('keywords',array('hash_keyword'=>$c));
		if ($query->num_rows() == 0) {
			return false;
		} else {
			return $query->row();
		}
	}

    	public function get_campaign()
	{
		$query = $this->db->get('keywords');
		if ($query->num_rows() == 0) {
			return false;
		} else {
			return $query->result();
		}
	}

}