sudsy1970 Posted October 25, 2010 Share Posted October 25, 2010 Hi all, have constructed a blog through some tutorials which will add and delete messages. I wish to add some form of confirmation box with a yes/no button before deleting but am not sure where to begin. Thanks for any help <?php // Command_BlogDelete.php //############################################################################ // SearchVenueCommand class //############################################################################ class Command_BlogDelete extends Command { //############################################################################ // doExecute //############################################################################ function doExecute(Request $request) { // Get data from request $id = $request->getProperty('id'); // Create manager object $manager = new ManagerMessage(); // Add to database $manager->deleteMessage($id); // Redirect to index header("location:index.php"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216807-object-oriented-php/ Share on other sites More sharing options...
ignace Posted October 25, 2010 Share Posted October 25, 2010 Why you used the Command pattern in a web environment to handle your requests is beyond me, MVC is much better suited. I wish to add some form of confirmation box with a yes/no button before deleting but am not sure where to begin. Well this is application logic and as such should be handled in the application, that is in your Controller (or in your case the Command). It could be something like: function doExecute(DeleteRequest $request) { if($request->isConfirmed()) { .. } } Quote Link to comment https://forums.phpfreaks.com/topic/216807-object-oriented-php/#findComment-1126335 Share on other sites More sharing options...
sudsy1970 Posted October 25, 2010 Author Share Posted October 25, 2010 Cheers for that, this was just the way we were required to code it. so i am guessing that the yes/no buttons will be generated in the views/index.php and the result POST'd back? Quote Link to comment https://forums.phpfreaks.com/topic/216807-object-oriented-php/#findComment-1126344 Share on other sites More sharing options...
ignace Posted October 25, 2010 Share Posted October 25, 2010 Cheers for that, this was just the way we were required to code it. so i am guessing that the yes/no buttons will be generated in the views/index.php and the result POST'd back? Yup. It should be noted that views are only present in a Model-View-Controller (MVC) architecture, so why you are required to mix patterns is also beyond me. Is this for class? Quote Link to comment https://forums.phpfreaks.com/topic/216807-object-oriented-php/#findComment-1126357 Share on other sites More sharing options...
sudsy1970 Posted October 25, 2010 Author Share Posted October 25, 2010 Thanks i will give that a go, seems very complicated as an introduction. And yes this is the way we are being taught. Quote Link to comment https://forums.phpfreaks.com/topic/216807-object-oriented-php/#findComment-1126388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.