Не выводит записи PHP MVC
Только изучаю MVC. Не могу понять в чем проблема.
Модель
<?php
class IndexModel extends Model {
public static function loadDepartment(){
$sql = "SELECT * from department";
$stmt = db::connToDB()->query($sql);
$stmt->fetch(PDO::FETCH_ASSOC);
$mass = array();
$i=1;
while($row=$stmt->fetch()) {
$mass[$i] = $row['departmentName'];
$i++;
}
return $mass;
}
}
Контроллер
<?php
class IndexController extends Controller {
private $pageTpl = '/views/main.tpl.php';
public function __construct() {
$this->model = new IndexModel();
$this->view = new View();
}
public function index() {
$this->pageData['title'] = "Вход в личный кабинет";
$this->view->render($this->pageTpl, $this->pageData);
$departmentList = array();
$departmentList = IndexModel ::loadDepartment();
require_once("view/main.tpl.php");
}
}
Вью
<?php foreach($departmentList as $key) { ?>
<option><?php print $key["departmentName"]?></option>