Executing multiple queries in codeigniter that cannot be executed one by one
Why not just write a stored procedure that does all the SQL you listed above taking the variables in your queries as parameters. Then just call the stored procedure as a single SQL statement;
$sql = "CALL some_sp($param1, $param2...etc)";
Maybe use transactions?
$this->db->trans_start();
$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');
$this->db->trans_complete();
https://www.codeigniter.com/user_guide/database/transactions.html