Pytam bo sie juz pogubilem z tym MVC przeczytalem wszystkie artykuly i posty na php.pl
Zrobilem tak
index.php
<?php
if($_REQUEST['action']){
require_once('actions/'.$_REQUEST['action'].'_action.php');
$action = new $_REQUEST['action'];
$action->$_REQUEST['method'];
$smarty->assign('');
$smarty->display();
}
?>
index tworzy kontroler i uruchamia metode
<?php
class soccer_score extends controller{
public function show_league_score(){
require_once('/model/soccer_score_model.php');
$mv = new show_league_score();
$mv->show_league_score();
}
}
?>
w modelu soccer_score_model.php
<?php
class modelAndView
{
private $db;
private $_model;
private $_view;
public function __construct()
{
$this->db = sPdo::getInstance;
}
public function getModel()
{
return $this->_model;
}
public function setModel($model_arr)
{
$this->_model = $model_arr;
}
public function addToModel($arr_key, $model_value)
{
$this->_model[$arr_key] = $model_value;
}
public function setView($view)
{
$this->_view = $view;
}
public function getView()
{
return $this->_view;
}
}
?>
<?php
class soccer_score_model extends modelAndView{
public function show_league_score(){
$this->addToModel('game',$this->get_game());
}
public function get_game(){
$query = $this->setQuery();
$stmt = $this->db->query($query);
return $stmt->fetchAll();
}
}
?>
Za widok uzywam Smarty
i teraz nie wiem czy dobrze robie bo nie wiem jak pobrac dane z modelu w index.php