How to delete the table record in magento using the foreign key.
I have a two table.
question(table 1)
--------
question_id
question
answer(table 2)
------
answer_id
question_id
answer
When I delete the question that corresponding answer also need to delete. I did the the question(table 1) record delete using the below method.
$model->load($id)
$model->setId($model->getQuestionId())->delete()
There have any way to delete the answer(table 2) record in the above method
Best Answer
Try this:
Assumption
answer/model
need to be replaced with your answer model name to call youranswer
model and$id
is question id.