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

class Product extends CI_Model { 
	function get_categories()
	{
		$this->db->select('*');
		$query = $this->db->get('categories');
		return $query->result_array();
	}
	function insert_product($data)
	{
		$this->db->insert('products',$data);
	}
	function get_cproducts($cat_id)
	{
		$this->db->select('*');
		$this->db->where('FK_category_id',$cat_id);
		$query = $this->db->get('products');
		return $query->result_array();
	}
	function get_cname($c_id)
	{
		$this->db->select('category_name');
		$this->db->where('category_id',$c_id);
		$query = $this->db->get('categories');
		return $query->row_array();
	}
	function rproducts()
	{
		$this->db->order_by('product_id', 'RANDOM');
		$this->db->limit(4);
		$query = $this->db->get('products');
		return $query->result_array();
	}
	function getproductname($p_id)
	{
		$this->db->select('product_name');
		$this->db->where('product_id',$p_id);
		$query=$this->db->get('products');
		return $query->row_array();
	}
}