2
I’m starting my studies in PHP. I need to make a logical deletion and although I’ve already found enough content on the subject, I can’t find how to exactly make the logical deletion in PHP. This is how I did mine (physics):
function remove( $table = null, $id = null ) {
$database = open_database();
try {
if ($id) {
$sql = "DELETE FROM " . $table . " WHERE id = " . $id;
$result = $database->query($sql);
if ($result = $database->query($sql)) {
$_SESSION['message'] = "Registro Removido com Sucesso.";
$_SESSION['type'] = 'success';
}
}
} catch (Exception $e) {
$_SESSION['message'] = $e->GetMessage();
$_SESSION['type'] = 'danger';
}
So far I understood that I need to put the date of deletion and just edit instead of delete, but I didn’t really understand how it works?
Thank you, Igor. Now you have clarified enough for me to try to implement.
– user67866