<?php
class MainController {
public function actionIndex(){
$model = new Model;
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$model->save($_POST['title'], $_POST['article']);
}
$data = $model->getAllArticles();
$this->render($data);
}
private function render($data){
$content = '';
while ($row = $data->fetchAll() ) {
$content .= "<h3>{$row['title']}</h3>";
$content .= "<p>{$row['article']}</p>";
}
}
}
PD9waHAKY2xhc3MgTWFpbkNvbnRyb2xsZXIgewogIHB1YmxpYyBmdW5jdGlvbiBhY3Rpb25JbmRleCgpewogICAgJG1vZGVsID0gbmV3IE1vZGVsOwogICAgaWYoJF9TRVJWRVJbJ1JFUVVFU1RfTUVUSE9EJ10gPT0gJ1BPU1QnKXsKICAgICAgJG1vZGVsLT5zYXZlKCRfUE9TVFsndGl0bGUnXSwgJF9QT1NUWydhcnRpY2xlJ10pOwogICAgfQogICAgJGRhdGEgPSAkbW9kZWwtPmdldEFsbEFydGljbGVzKCk7CiAgICAkdGhpcy0+cmVuZGVyKCRkYXRhKTsKICB9CiAgcHJpdmF0ZSBmdW5jdGlvbiByZW5kZXIoJGRhdGEpewogICAgJHZpZXcgPSBmaWxlX2dldF9jb250ZW50cygndGVtcGxhdGUudHBsJyk7CiAgICAkY29udGVudCA9ICcnOwogICAgd2hpbGUgKCRyb3cgPSAkZGF0YS0+ZmV0Y2hBbGwoKSApIHsKICAgICAgJGNvbnRlbnQgLj0gIjxoMz57JHJvd1sndGl0bGUnXX08L2gzPiI7CiAgICAgICRjb250ZW50IC49ICI8cD57JHJvd1snYXJ0aWNsZSddfTwvcD4iOwogICAgfQogICAgZWNobyBzdHJfcmVwbGFjZSgne3tjb250ZW50fX0nLCAkY29udGVudCwgJHZpZXcpOwogIH0KfQ==