CodeIgniter Forums

Full Version: MY_Model construct not working?!?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]fatnic[/eluser]
Trying to run this bit of code (just to test) and having problems with $this->table_name.

Code:
class MY_Model extends Model {

    var $table_name;

    function MY_Model() {
        parent::Model();
        $this->table_name = 'whatever';
    }

    function getAll() {
        return $this->table_name;
    }

}
When I call getAll() the above code returns nothing. However, when I set the table name in the getAll() function it work perfectly. What am I doing wrong?!?!?

El Forum

[eluser]fatnic[/eluser]
Solved now. I was being an idiot.

I was still calling
Code:
parent::Model();
in the test model file instead of
Code:
parent::MY_Model();

Whooooooops!!!