Magento – Magento 1 custom Model, Can’t get data from table

databasemagento-1.9

I created my own module, the table is created in the database and in a phtml I can call:

$res = $model->getExample();

and effectively it function is called.

In Model:

protected function _construct() {
    $this->_init('table_name', 'column_id');
}
public function getExample(){
    $result = $this->getData();
}

but 'result' is empty and I know there're data in a database, so… what's the problem?

CLUES

gettype($this) // is object

$this->load() // Call to a member function load() on a non-object

Best Answer

You can use

Mage::getModel('modulename/modulename')->yourMethod();
Related Topic