- // We shall do it in a straightforward way by a delete operation from all tables by org_id.
- // However, at this time not all tables have org_id.
- // So, we need to add the field as we write code here.
-
- // Delete predefined expenses.
- $sql = "delete from tt_predefined_expenses where org_id = $org_id";
- $affected = $mdb2->exec($sql);
- if (is_a($affected, 'PEAR_Error')) return false;
-
- // Delete monthly quotas.
- $sql = "delete from tt_monthly_quotas where org_id = $org_id";
- $affected = $mdb2->exec($sql);
- if (is_a($affected, 'PEAR_Error')) return false;
+ // Go one table at a time and remove all records with matching org_id.
+ // The order is backwards to import (see ttOrgImportHelper). Remove groups last.
+ // This leaves us with something partially working if an error occurs.
+ $mdb2 = getConnection();