[eluser]swgj19[/eluser]
This is the error I am getting:
Fatal error: Class 'Mcats' not found in C:\xampp\htdocs\shopping\system\core\Loader.php on line 303
mcats.php is my model:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Categories_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function get_category($id)
{
$data = array();
$options = array('id' => $id);
$query = $this->db->getwhere('categories', $options, 1);
if ($query->num_rows() > 0)
{
$data = $query->row_array();
}
$query->free_result();
return $data;
}
function get_all_categories()
{
$data = array();
$query = $this->db->get('categories');
if ($query->num_rows() > 0)
{
foreach ($query->result_array() as $row)
{
$data[] = $row;
}
}
$query->free_result();
return $data;
}
function get_sub_categories($cat_id)
{
$data = array();
$this->db->select('id, name, shortdesc');
$this->db->where('parentid', $cat_id);
$this->db->where('status', 'active');
$this->db->orderby('name', 'asc');
$query = $this->db->get('categories');
if ($query->num_rows() > 0)
{
foreach ($query->result_array() as $row)
{
$sql = "select thumbnail as src
from products
where category_id=" . $row['id'] . "
And status='active'
order by rand() limit 1";
$query2 = $this->db->query($sql);
if ($query2->num_rows() > 0)
{
$thumb = $query2->row_array();
$thumbnail = $thumb['src'];
}
else
{
$thumbnail = '';
}
$query2->free_result();
$data[] = array(
'id' => $row['id'],
'name' => $row['name'],
'shortdesc' => $row['shortdesc'],
'thumbnail' => $thumbnail
);
}
}
$query->free_result();
return $data;
}
function get_categories_nav()
{
$data = array();
$this->db->select('id, name, parent_id');
$this->db->where('status', 'active');
$this->db->orderby('parent_id', 'asc');
$this->db->orderby('name', 'asc');
$this->db->groupby('parent_id, id');
$query = $this->db->get('categories');
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
if ($row->parentid > 0)
{
$data[0][$row->parentid]['children'][$row->id] = $row->name;
}
else
{
$data[0][$row->id]['name'] = $row->name;
}
}
}
$query->free_result();
return $data;
}
function getCategoriesDropDown()
{
$data = array();
$this->db->select('id, name');
$this->db->where('parent_id !=', 0);
$query = $this->db->get('categories');
if ($query->num_rows() > 0)
{
foreach ($query->result_array() as $row)
{
$data[$row['id']] = $row['name'];
}
}
$query->free_result();
return $data;
}