Please excuse me, I'm relatively new to CI, although I've made a couple of site's based on it, I'm still fairly "green".

I've come across a weird situation involving an array in a model. I'm try to make a standard "shopping cart" (called a "quick quote" in this instance) comprising of one "Quick_quote_cart_model" object containing many "Quick_quote_item_model" objects.

The items are stored in an array called $cart_items which is a property of the "Quick_quote_cart_model" object.

Here's the relevant code snippets, first the "Quick_quote_cart_model":

“Fatal error: Cannot use object of type Quick_quote_cart_model as array in C:\xampp\htdocs\tm_v2\application\models\quick_quote_cart_model.php on line 36”

I’m baffled. This code is based on a non-CI system that works perfectly, so the theory as far as I can see is sound.

Even more bizarrely, if you remove the “$this->” the assignment lines of the “Quick_quote_cart_model->Add_cart_item()” function, it’ll get past the initial error (causing more problems further down the line).

I’m assuming this is some sort of scope issue but I really have no idea what’s going on.

One of the lines I removed from the code snippets retrieved the cart object from the session. Instead of then getting the array from the cart object and using that for further processing, I was using the object itself, causing some sort of circular assign itself to itself schenanigans.