Welcome Guest, Not a member yet? Register   Sign In
Undefined property Cart::$Cart_model
#1

[eluser]Unknown[/eluser]
Hello,

I've started to learn CI but I stuck at the beginning.. I following one tutorial where I must creat a Cart. What I've done is in controler/cart.php i have:
Code:
class Cart extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model('cart_model');
    }
    function index(){
        $data['cart'] = $this->Cart_model->retrieve_products();
        print_r($data['cart']);
    }

In models/cart_model.php
Code:
class Cart_model extends CI_Model {

    function retrieve_products(){
        $this->db->get('cart');
        return $this->result_array();
    }
}
The error that I get is
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Cart::$Cart_model

Filename: controllers/cart.php

Line Number: 8
Line number 8 -> $data['cart'] = $this->Cart_model->retrieve_products();

I have found some solutions in Google but none of them working in my case. Can someone explain what is wrong here?

Thank's in advance

p.s. Excuse my English... Still learn it Smile
#2

[eluser]InsiteFX[/eluser]
In your index method Cart_model should be lowercase cart_model
#3

[eluser]Unknown[/eluser]
Oh, this case sensitivity. Thank's for your help!




Theme © iAndrew 2016 - Forum software by © MyBB