Простий приклад реалізації MVC на PHP

<u>foo.php</u> <?php
$db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password');

// Make your model available
include 'models/FooModel.php';

// Create an instance
$fooModel = new FooModel($db);
// Get the list of Foos
$fooList = $fooModel->getAllFoos();

// Show the view
include 'views/foo-list.php';

<u>models/FooModel.php</u>
<?php
class FooModel
{
    protected $db;

    public function __construct(PDO $db)
    {
        $this->db = $db;
    }

    public function getAllFoos() {
        return $this->db->query('SELECT * FROM table');
    }
}

<u>views/foo-list.php</u>
<?php foreach ($fooList as $row): ?><?= $row['field1'] ?>- <?= $row['field1'] ?><?php endforeach ?>