模型视图控制器中的回声

时间:2017-11-13 18:47:47

标签: php model-view-controller

我是MVC的新手,我需要在View中回显我数据库中的数据。任何人都可以帮助我吗?这是代码:

控制器:

class Index extends Controller {

  function __construct() {
    parent::__construct();
    //echo 'We are in index';
  }

  function index(){
    $this->view->render('index/index');
  }

  function get(){
    $this->model->get();
  }
}

型号:

class Index_Model extends Model {

  public function __construct()
  {
    parent::__construct();
  }

  function get()
  {
    $sth = $this->db->prepare('SELECT * FROM data');
    $sth->setFetchMode(PDO::);
    $sth->execute();
    $sth->fetchAll();
  } 
}

如何在View中回显?

0 个答案:

没有答案