Kod jest krótki chodzi o pobranie wszystkich newsów.
news.model.php
<?php //MVC Próba 1 class News { public function __construct($db) { $this->db = $db; } public function GetNews() { return $this->db->query_fetch('SELECT * FROM news ORDER BY id DESC'); } } ?>
news.view.php
<?php class NewsView { public function SetData($data) { $this->data = $data; } public function RenderAllNews() { foreach($this->data as $row) { } } } ?>
news.controller.php
<?php $news = new News($db); $view = new NewsView; $data = $news->GetNews(); $view->SetData($data); $view->RenderAllNews(); ?>