mvp.10
This commit is contained in:
parent
953eb569ce
commit
b2e9c01463
@ -6,16 +6,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id'])) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$pdo = db();
|
$pdo = db();
|
||||||
$stmt = $pdo->prepare("DELETE FROM processes WHERE id = :id");
|
$pdo->beginTransaction();
|
||||||
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
|
|
||||||
if ($stmt->execute()) {
|
// Delete associated steps first
|
||||||
|
$stmtSteps = $pdo->prepare("DELETE FROM process_steps WHERE process_id = :id");
|
||||||
|
$stmtSteps->bindParam(':id', $id, PDO::PARAM_INT);
|
||||||
|
$stmtSteps->execute();
|
||||||
|
|
||||||
|
// Then delete the process
|
||||||
|
$stmtProcess = $pdo->prepare("DELETE FROM processes WHERE id = :id");
|
||||||
|
$stmtProcess->bindParam(':id', $id, PDO::PARAM_INT);
|
||||||
|
if ($stmtProcess->execute()) {
|
||||||
|
$pdo->commit();
|
||||||
header('Location: index.php?success=processdeleted');
|
header('Location: index.php?success=processdeleted');
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
|
$pdo->rollBack();
|
||||||
header('Location: index.php?error=deletionfailed');
|
header('Location: index.php?error=deletionfailed');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
$pdo->rollBack();
|
||||||
error_log("DB Error: " . $e->getMessage());
|
error_log("DB Error: " . $e->getMessage());
|
||||||
header('Location: index.php?error=dberror');
|
header('Location: index.php?error=dberror');
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user