Pertemuan 11 PHP MVC 1
Pertemuan 11 PHP MVC 1
the data
The view (presentation) is
class Model {
public function getBookList()
{
// here goes some hardcoded values to simulate the database
return array(
"Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."),
"Moonwalker" => new Book("Moonwalker", "J. Walker", ""),
"PHP for Dummies" => new Book("PHP for Dummies", "Some Smart Guy", "")
);
}
public function getBook($title)
{
// we use the previous function to get all the books
// and then we return the requested one.
// in a real life scenario this will be done through
// a database select command
$allBooks = $this->getBookList();
return $allBooks[$title];
}
}
?>
view/viewbook.php
<html>
<head></head>
<body>
<?php
?>
</body>
</html>
view/booklist.php
<html>
<head></head>
<body>
<table>
<tbody>
<tr><td>Title</td><td>Author</td><td>Description</td></tr>
</tbody>
<?php
class Controller {
public $model;
include_once("controller/Controller.php");
?>
PHP & MVC