delete
delete.php – where todo items go to die
//Last time, we are using Prosper
namespace Prosper;
//Configure Prosper
require_once 'config.php';
if($_SERVER['REQUEST_METHOD'] == 'POST') {
//Delete the todo and redirect
Query::delete() //Delete
->from('todo') //From 'todo' table
->where("id = :id", $_POST) //Named param
->execute(); //Goodbye todo
//Redirect to index
header("Location: index.php");
} else {
//Pretty header
include_once 'header.php';
//What todo are we deleting
$todos = Query::select() //Select *
->from('todo') //From 'todo' table
->where("id = :id", $_GET) //IDs on the query string
->execute(); //Go get it
//Only one record
$todo = $todos[0];
//Simple mark-up action="delete.php" method="post"
delete_form($todo);
//Pretty footer
include_once 'footer.php';
}
And the final piece of functionality, deleting a todo. There is really no new interesting feature of Prosper to show here, again we have named parameters that we can use to delete and select.