I would like to create a delete-method, which deletes an entry in a table AND the attached entries in a second table.
This is my source so far:
// Delete entry in users_handles
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$conditions = array(
$db->quoteName('userid') . ' = ' . $db->quote((int)$userid),
$db->quoteName('type') . ' = ' . $db->quote($type),
);
$query->delete($db->quoteName('#__bestia_users_handles'));
$query->where($conditions);
$db->setQuery($query);
$result = $db->execute();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$conditions = array($db->quoteName('handleid') . ' = ' . GET ID FROM ENTRY THAT HAS BEEN DELETED BEFORE));
$query->delete($db->quoteName('#__bestia_users_handles_mapping'));
$query->where($conditions);
$db->setQuery($query);
$result = $db->execute();
Is this possible?
bestia_users_handles_mapping
table should have a column such asuser_id
,uid
or any other name that associates the data in this table with the other one