Created
November 26, 2012 12:44
-
-
Save mpmont/4148021 to your computer and use it in GitHub Desktop.
hmvc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<?php foreach($news as $article): ?> | |
<li><?= $article->title ?></li> | |
<?php endforeach; ?> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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