Download Flexi Custom Code Module from the JED.
Install the module and publish it to the position of your choice.
Below the custom code box leave the option to use PHP on and disable the cleanup of html, js, and css.
Enter this code into the custom code box:
$JInput = JFactory::getApplication()->input;
You are calling parent::publish(). This method has an array which maps tasks to states (line 190):
$data = array('publish' => 1, 'unpublish' => 0, 'archive' => 2, 'trash' => -2, 'report' => -3);
Then it gets the task (next line):
$task = $this->getTask();
Which is "setup" in your case.
After that it tries to read the value of the task ...
You can definitely delete rows from multiple tables in a single query, but Joomla doesn't offer a query-building technique to accommodate this.
If you absolutely demand that query builder methods must be used, then you'll need to conduct some "surgery" (which isn't very pretty) on the generated query before executing it -- see https://joomla....
Why don't you do it in 2 steps?
I would do something like the following code. As you can see I use name spacing (since Joomla 3.8), used quoteName the table + field names and added a try/catch block.
public function delete_codes()
$id = $this->input->getInt('id');
$query = $db->getQuery(true)