I've searched the internet for a good answer to this question but with no results. I'm trying to delete multiple rows in another table than from where the component is being executed.
Basically, when I delete 4 rows in component A, these rows also have to be deleted in component B. The key exists in the other table so that's not a problem. I can easily do it with some quick and dirty mysql queries but I want to do it with Joomla's built in methods.
In joomla the delete method is used from JControllerAdmin where a model is grabbed with getModel and then another delete method is executed. But I can't seem to find where this delete method is located which actually deletes the rows.
BTW I have copy pasted the delete method from JControllerAdmin and pasted it in my own controller. I did change the name but everything works
So now I have turned to Stackoverflow to get help with my problem. Long story short: I have a customDelete() method which is an identical copy of the delete method from JControllerAdmin class and I want to add functionality which allows me to use the id's which are in the customDelete() method to delete rows in another table.
I hope this is clear :)
Thanks!
EDIT:
This is the delete method in the controller. I have to delete all the rows from #__modeling
(the table corresponding to Component B) containing the id's inside $cid
public function customDelete() {
// Check for request forgeries
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// Get items to remove from the request.
$cid = JRequest::getVar('cid', array(), '', 'array');
if (!is_array($cid) || count($cid) < 1) {
JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
} else {
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
jimport('joomla.utilities.arrayhelper');
JArrayHelper::toInteger($cid);
// Remove the items.
if ($model->delete($cid)) {
$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
} else {
$this->setMessage($model->getError());
}
}