Welcome Guest, Not a member yet? Register   Sign In
Error in "Claudia's Kids" wrox shopping cart tutorial
#1

[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;
}
#2

[eluser]antoniog[/eluser]
Hi,
replace Categories_model or Categories with MCats.
I'm also reading the manual "Professional CodeIgniter" and I had to modify the file mcats.php, the Model master class in CI_Model and now runs fine.
#3

[eluser]antoniog[/eluser]
Set this:
Code:
$autoload['model'] = array('MProducts', 'MCats');
#4

[eluser]InsiteFX[/eluser]
That has nothing to do with it all the code is for CI 1.7.2
Code:
// all models and controllers need this code changes!
orderby = order_by
getwhere = get_where
etc!
Controller = CI_Controller
Model = CI_Model
etc
Want me to go on?

There are lots of errors in the view files also...

Plus there are lots of other errors in the code that needs to be fixed!

It does not use CodeIgniters Shopping Cart Class...
#5

[eluser]antoniog[/eluser]
[quote author="InsiteFX" date="1334913384"]That has nothing to do with it all the code is for CI 1.7.2
Code:
// all models and controllers need this code changes!
orderby = order_by
getwhere = get_where
etc!
Controller = CI_Controller
Model = CI_Model
etc
Want me to go on?

There are lots of errors in the view files also...

Plus there are lots of other errors in the code that needs to be fixed!

It does not use CodeIgniters Shopping Cart Class...
[/quote]

Thank you.
#6

[eluser]Unknown[/eluser]
Hi Steven an InsiteFX,

i found also some bugx in the book before i looked to the erratas-site. Can you please send me your claudias Kids Shop it would be great. Thanx very Robert




Theme © iAndrew 2016 - Forum software by © MyBB