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])
 
(87 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Main Page]] >> [[CP3207|Web Application Development]] >> [[Web Application Developpment - Workbook|Workbook]] >> Week 04
+
[[Main Page]] >> [[6CC001|Advanced Web Technologies]] >> [[6CC001 - Workbook|Workbook]] >> Week 04
  
== Create and populate database ==
+
Your job today is to implement a blog similar to this one:
 +
* [http://mi-linux.wlv.ac.uk/~in9352/OO/blog/index.php http://mi-linux.wlv.ac.uk/~in9352/OO/blog/index.php]
  
<pre>
+
The different steps are:
CREATE TABLE IF NOT EXISTS `messages` (
 
  `id` int(11) NOT NULL auto_increment,
 
  `title` varchar(255) NOT NULL,
 
  `message` text NOT NULL,
 
  `date_added` datetime NOT NULL,
 
  PRIMARY KEY  (`id`)
 
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
 
  
INSERT INTO `messages` (`id`, `title`, `message`, `date_added`) VALUES
+
# [[DesignPatternStep1|Step 1]] - Create and populate database
(17, 'Test 1', 'Hello world!', '2009-07-27 15:06:29'),
+
# [[DesignPatternStep2|Step 2]] - Create the index.php file, front controller and registry class
(18, 'Test 2', 'Hiya', '2009-07-27 15:06:38');
+
# [[DesignPatternStep3|Step 3]] - Handling user request and creating appropriate command
</pre>
+
# [[DesignPatternStep4|Step 4]] - Accessing the database
 +
# [[DesignPatternStep5|Step 5]] - Creating our first view
 +
# [[DesignPatternStep6|Step 6]] - Adding messages
 +
# [[DesignPatternStep7|Step 7]] - Deleting messages
  
== Create index.php file ==
+
Let's take it one step at a time... and remember: read and understand the code before pasting it into your text editor!
 
 
<pre>
 
// The index simply calls the front controller
 
require("Controller.php");
 
Controller::run();
 
</pre>
 
 
 
== Create Registry class ==
 
 
 
<pre>
 
//############################################################################
 
// Registry class, used to store values to be used across whole application
 
//############################################################################
 
class Registry
 
{
 
  private static $values = array();
 
 
 
  //############################################################################
 
  // Store a value
 
  //############################################################################   
 
  static function set($key, $val)
 
  {
 
    self::$values[$key] = $val;
 
  }
 
 
 
  //############################################################################
 
  // Get a value
 
  //############################################################################   
 
  static function get($key)
 
  {
 
    if(isset(self::$values[$key]))
 
    {
 
      return self::$values[$key];
 
    }
 
    return null;
 
  }
 
 
 
}
 
</pre>
 

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!