Я пытаюсь изучить архитектуру MVC для PHP. Поэтому я играю с некоторыми простыми классами и функциями. Я не могу найти, что не так с этим кодом, который возвращает:
Неустранимая ошибка: Вызов функции-члена fetch () для необъекта в
/opt/lampp/htdocs/test/MVC/Vue.php на
строка 15
Вот мой код:
Model.php:
class News {
public function ConnBdd() {
$this->bdd = new PDO('mysql:host=localhost;dbname=db301591273', 'root', '');
$this->query = "SELECT Nom,IdTest,Image,DATE_FORMAT(DateCreation, '%Y-%m-%d') AS DateCreation FROM Questionnaires WHERE autorise='1' ORDER BY DateCreation DESC LIMIT 0, 4";
$this->preparedQuery = $this->bdd->prepare($this->query);
$this->executedQuery = $this->preparedQuery->execute();
}
}
Controller.php
class Controller {
public $Model;
public $View;
public $News;
public function ShowNews(){
$this->News->ConnBdd();
$this->View->ShowDaNews();
}
}
view.php
class View {
public $Model;
public $News;
public function ShowDaNews() {
while ($c = $this->News->executedQuery->fetch()) {?>
<tr>
<td class="tableImg"><?echo '<img src="/img/ico/'.$tests['Image'].'.png" />'?></td>
<td class="tableTest"><?echo '<a href="/page/php?t='.$tests['IdTest'].'">'.$tests['Nom'].'</a>'?></td>
</tr>
<?}
}
}
и Index.php
require_once 'Modele.php';
require_once 'Controleur.php';
require_once 'Vue.php';
$Model= new Model();
$Controller = new Controller();
$View = new View();
$Controller->Model = $Model;
$Controller->View = $View;
$News = new News();
$Controller->News = $News;
$View->News = $News;
$Controller->ShowNews();
Спасибо за вашу помощь.