Jump to content

How to echo in Model View Controller


ramplstilskin

Recommended Posts

I am new to MVC and I need to echo data from my database in View. Can anyone help me with that. Here is the code:

Controller:

 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();
 }
 }

Model:

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();
 }
 }

How to echo data from database in View?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.