How to insert value to Magento database using module
- by Kasmin Nicko
I want to insert value to the database I created. The value would be insert to post column.
I have code like this in the IndexController.php
class My_Module_IndexController extends Mage_Core_Controller_Front_Action {
public function postAction() {
$post = Mage::getModel('my/model');
$post->setPost('My Post Here');
$post->save();
}
}
But after I ran this script, I got the following error
Fatal error: Call to a member function setPost() on a non-object in C:\xampp\htdocs\magento\app\code\community\My\Module\controllers\IndexController.php on line 7
What is something I miss?