/** * Returns an singleton instance of this class * @return */ public static function getInstance() { if (self::$instance == null) { self::$instance = new ItemMapper(); } return self::$instance; }
function items($items = null) { if (is_null($items)) { //getting items if (isset($this->items)) { return $this->items; } else { $this->items = ItemMapper::instance()->find_all_by_sql('feed_id = ' . $this->id()); return $this->items; } } else { //setting items $this->items = $items; } }
function mapper() { return ItemMapper::instance(); }
<?php include 'header.php'; $item = ItemMapper::instance()->find($_GET['id']); ?> <?php $feed_helper = new FeedHelper(); ?> <?php echo $feed_helper->link($item->feed()); ?> <h2><?php echo $item->title(); ?> </h2> <?php echo $item->body(); include 'footer.php';