Skip to content

Instantly share code, notes, and snippets.

@mpmont
Created November 26, 2012 12:44
Show Gist options
  • Save mpmont/4148021 to your computer and use it in GitHub Desktop.
Save mpmont/4148021 to your computer and use it in GitHub Desktop.
hmvc
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class News extends CI_Controller {
public function index()
{
$this->load->model('news_model', 'article');
$data['news] = $this->article->get_all();
$this->load->view('news_list', $data);
}
}
/* End of file news.php */
/* Location: ./application/modules/controllers/news.php */
<ul>
<?php foreach($news as $article): ?>
<li><?= $article->title ?></li>
<?php endforeach; ?>
</ul>
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class News_Model extends CI_Model {
public function get_all(){
$query = $this->db->get('news');
return $query->result();
}
}
/* End of file news_Model.php */
/* Location: ./application/models/news_Model.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment