Difference between revisions of "6CC001 Workshop - week 04"

From mi-linux
Jump to navigationJump to search
m (Protected "6CC001 Workshop - week 04" [edit=sysop:move=sysop])
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
  
 
Let's take it one step at a time... and remember: read and understand the code before pasting it into your text editor!
 
Let's take it one step at a time... and remember: read and understand the code before pasting it into your text editor!
 
 
 
 
 
 
== Step 7 - Deleting messages ==
 
 
Finally, let’s create a new action in charge of message deletion.
 
 
Again if you browse the mouse over the “delete this message” links, you will see URLs such as “index.php?cmd=BlogDelete&id=19”
 
 
So we need a new Command_BlogDelete class. Here is the code:
 
 
<pre>
 
// 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");
 
  }
 
}
 
</pre>
 
 
Nothing too complicated here...
 
 
=== Checkpoint ===
 
 
You should now be able to delete messages.
 
 
Note: It is always better practice to ask users to confirm deletion first... but you can do that bit&nbsp;;)
 

Latest revision as of 14:57, 22 September 2011

Main Page >> Advanced Web Technologies >> Workbook >> Week 04

Your job today is to implement a blog similar to this one:

The different steps are:

  1. Step 1 - Create and populate database
  2. Step 2 - Create the index.php file, front controller and registry class
  3. Step 3 - Handling user request and creating appropriate command
  4. Step 4 - Accessing the database
  5. Step 5 - Creating our first view
  6. Step 6 - Adding messages
  7. Step 7 - Deleting messages

Let's take it one step at a time... and remember: read and understand the code before pasting it into your text editor!