0

Clear like the title. I want to insert data into my new create table. How to write code, with what method?

Please help me, thanks!

1 Answer 1

3

Magento use MVC structure,So you need to create a custom module,which are an installer script and a model

  • First create a database table using installer script.
  • Then create a model for this table.
  • Now using model you can save your data at database.

See more details at

Assume that you have using first referecne then for insert a new record at table you can use below code:

$model=Mage::getModel('custommodule/custommodule');
$model->setData('product_id',12);
$model->setData('customer_name','Testin test');
$model->setData('customer_email','[email protected]');
$model->setData('question','Why?');
...
$model->save(); /* use save() for save data at table */
1
  • 1
    Thanks, Amit Bera! My situation is different, my data is an array of multiple data. Finally, I got it by method 'insertOnDuplicate()'.
    – Jeffery
    Apr 27, 2016 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.