Hello again, here is what I am using just now. The script was posted on another thread the other day there, but here it is again.
Hope you can (from this script) understand the important of using Setters and Getters, ie If the database field names had to change, I'd only need to alter the Setters and Getters, and not the script (client) that actually uses the ''Archives'' 
PHP Code:
# modules/news/news.class.php
<?php
class NewsGateway {
function NewsGateway() {
}
function FindAllWithAuthor( &$db ) {
$findAllWithAuthor = "SELECT
fld_id,
UNIX_TIMESTAMP( fld_date ) AS fld_date,
fld_body,
fld_title,
fld_status FROM tbl_news ORDER BY fld_date DESC";
return $db -> Execute( $findAllWithAuthor );
}
function FindById( &$db, $id ) {
$findById = "SELECT
fld_id,
UNIX_TIMESTAMP( fld_date ) AS fld_date,
fld_body,
fld_title,
fld_status FROM tbl_news WHERE fld_id = '".$id."'";
return $db -> Execute( $findById );
}
}
class NewsManager {
function NewsManager() {
}
function Load( &$resultset, $archiver ) {
$indexer = array();
$iterator = &new QueryIterator( $resultset );
while( $iterator -> IsValid() ) {
$row = $iterator -> GetCurrent();
$iterator -> GetNext();
#
$archive = &new $archiver;
$archive -> Invoke( $row );
$indexer[] = &$archive;
}
return $indexer;
}
function Update() { } // update database records
function Insert( &$db, $title, $body, $status ) {
$sql = "INSERT INTO tbl_news SET
fld_date = now(),
fld_body = '".$body."',
fld_title = '".$title."',
fld_status = '".$status."'";
$db -> Execute( $sql );
}
function Delete() { } // delete database records
}
class NewsArchiver {
var $indexer;
function NewsArchiver() {
$this -> indexer = array();
}
function SetId( $id ) {
$this -> indexer['id'] = $id;
}
function SetDate( $date ) {
$this -> indexer['date'] = $date;
}
function SetBody( $body ) {
$this -> indexer['body'] = $body;
}
function SetTitle( $title ) {
$this -> indexer['title'] = $title;
}
function SetStatus( $status ) {
$this -> indexer['status'] = $status;
}
}
class FindAllWithAuthorArchive extends NewsArchiver {
function FindAllWithAuthorArchive() {
NewsArchiver::NewsArchiver();
}
function Invoke( $row ) {
$this -> SetId( $row['fld_id'] );
$this -> SetDate( $row['fld_date'] );
$this -> SetBody( $row['fld_body'] );
$this -> SetTitle( $row['fld_title'] );
$this -> SetStatus( $row['fld_status'] );
}
function GetId() {
return $this -> indexer['id'];
}
function GetDate() {
return $this -> indexer['date'];
}
function GetBody() {
return $this -> indexer['body'];
}
function GetTitle() {
return $this -> indexer['title'];
}
function GetStatus() {
return $this -> indexer['status'];
}
}
class FindByIdArchive extends NewsArchiver {
function FindByIdArchive() {
NewsArchiver::NewsArchiver();
}
function Invoke( $row ) {
$this -> SetId( $row['fld_id'] );
$this -> SetDate( $row['fld_date'] );
$this -> SetBody( $row['fld_body'] );
$this -> SetTitle( $row['fld_title'] );
$this -> SetStatus( $row['fld_status'] );
}
function GetId() {
return $this -> indexer['id'];
}
function GetDate() {
return $this -> indexer['date'];
}
function GetBody() {
return $this -> indexer['body'];
}
function GetTitle() {
return $this -> indexer['title'];
}
function GetStatus() {
return $this -> indexer['status'];
}
}
?>
The above is used by this parts 
PHP Code:
class ShowNewsController {
var $view;
function ShowNewsController() {
}
function GetPage() {
return $this -> view;
}
function Execute() {
$id = (int) $_GET['id'];
require_once( 'modules/news/news.class.php' );
$db = singleton::getInstance();
$model = NewsManager::Load( NewsGateway::FindById( &$db, $id ), 'FindByIdArchive' );
$this -> view = &new ShowNewsView( &$model );
}
}
class ShowNewsView extends BasePageView {
var $model;
var $title = 'Administer your sites news';
var $heading = 'News :: View Item';
function ShowNewsView( &$model ) {
BasePageView::BasePageView( 'templates/show-news.template.htm', 'templates/basic.template.top.htm' );
$this -> model = &$model;
}
function Finalise() {
$this -> Paste( '<page_body />', $this -> Fetch() );
$this -> Paste( '<page_heading />', $this -> heading );
$iterator = &new ArrayIterator( $this -> model );
$row = $iterator -> GetCurrent();
$this -> Paste( '<page_news_id />' , $row -> GetId() );
$this -> Paste( '<page_news_body />', $row -> GetBody() );
$this -> Paste( '<page_news_date />', date( DATE_LONGFORMAT, $row -> GetDate() ) );
$this -> Paste( '<page_news_title />', $row -> GetTitle() );
$this -> Paste( '<page_news_status />', $row -> GetStatus() == (int) 1 ? 'Yes':'Pending' );
}
}
class AddNewsController {
var $view;
function AddNewsController() {
}
function GetPage() {
return $this -> view;
}
function Execute() {
if( isset( $_POST['BasicSubmit'] ) ) {
# user has requested to add a news item
$body = (string) addslashes( $_POST['Body'] );
$title = (string) $_POST['Title'];
$status = (int) isset( $_POST['Status'] )? 1:0;
$db = singleton::getInstance();
require_once( 'modules/news/news.class.php' );
# implement Model layer
NewsManager::Insert( &$db, $title, $body, $status );
$this -> view = new AddNewsViewSuccess;
}
else {
$this -> view = &new AddNewsView( &$model );
}
}
}
class AddNewsView extends BasePageView {
var $model;
var $title = 'Administer your sites news';
var $heading = 'News :: Add Item';
function AddNewsView( &$model ) {
BasePageView::BasePageView( 'templates/add-news.template.htm', 'templates/basic.template.top.htm' );
$this -> model = &$model;
}
function Finalise() {
$this -> Paste( '<page_body />', $this -> Fetch() );
$this -> Paste( '<page_heading />', $this -> heading );
}
}
class AddNewsViewSuccess extends BasePageView {
var $title = 'Administer your sites news';
var $heading = 'News :: Add An Item';
function AddNewsViewSuccess() {
BasePageView::BasePageView( 'templates/add-news-success.template.htm', 'templates/basic.template.centre.htm' );
}
function Finalise() {
$this -> Paste( '<page_body />', $this -> Fetch() );
$this -> Paste( '<page_heading />', $this -> heading );
}
}
class NewsController {
var $view;
function NewsController() {
}
function GetPage() {
return $this -> view;
}
function Execute() {
require_once( 'modules/news/news.class.php' );
$db = singleton::getInstance();
$model = NewsManager::Load( NewsGateway::FindAllWithAuthor( &$db ), 'FindAllWithAuthorArchive' );
$this -> view = &new NewsView( &$model );
}
}
class NewsView extends BasePageView {
var $model;
var $title = 'Administer your sites news';
var $heading = 'News :: Administration';
function NewsView( &$model ) {
# defaults, $page = templates/admin.body.htm,
# defaults, $template = templates/basic.template.centre.htm
BasePageView::BasePageView( 'templates/news.template.htm', 'templates/basic.template.top.htm' );
$this -> model = &$model;
}
function Finalise() {
$this -> Paste( '<page_body />', $this -> Fetch() );
$this -> Paste( '<page_heading />', $this -> heading );
$html = '';
$iterator = &new ArrayIterator( $this -> model );
while( $iterator -> IsValid() ) {
$row = $iterator -> GetCurrent();
$iterator -> GetNext();
#
$content = &new ViewHelper( 'templates/modules/news.template.htm' );
$content -> Paste( '<page_news_id />', $row -> GetId() );
$content -> Paste( '<page_news_date />', date( DATE_LONGFORMAT, $row -> GetDate() ) );
$content -> Paste( '<page_news_published />', $row -> GetStatus() == (int) 1 ? 'Yes':'Pending' );
$content -> Paste( '<page_news_title />', $row -> GetTitle() );
$html .= $content -> Finalise();
}
$this -> Paste( '<page_news_list />', $html );
}
}
Session::Start();
$page = &new Page;
$page -> Dispatch();
Enjoy
Bookmarks