I am creating my own module and everything was going well until i started creating my own models.
I'm trying to query a database table I've added (which has data) and all i want to do is print the data.
When i view the page which calls the module, I get the following message
Fatal error: Call to a member function load() on a non-object
on this line
$model = Mage::getResourceModel('facebooklikediscount/facebookcoupon')->load(1);
Here is my config.xml (the model part)
MyModule_FacebookLikeDiscount_Model
mymodule_facebooklikediscount_resource
MyModule_FacebookLikeDiscount_Model_Resource
mymodule_facebooklikediscount_mysql4
salesrule_coupon_facebook
My model
_init('facebooklikediscount/facebookcoupon');
}
}
Resource model
_init('facebooklikediscount/facebookcoupon', 'entity_id');
$this->_storeId = (int)Mage::app()->getStore()->getId();
}
public function getData($entityId)
{
$resource = Mage::getSingleton('core/resource');
$select = $resource->getConnection('core_read')->select();
$select
->from($this->getTable(array('facebooklikediscount/facebookcoupon', $this->_storeId)), '*')
->where('entity_id = :entity_id');
$result = $resource->getConnection('core_read')->fetchAll($select, array('entity_id' => $entityId));
return $result;
}
}