Skip to content

Instantly share code, notes, and snippets.

@KyeRussell
Created January 6, 2011 16:10
Show Gist options
  • Save KyeRussell/768081 to your computer and use it in GitHub Desktop.
Save KyeRussell/768081 to your computer and use it in GitHub Desktop.
?
<?php
/* my model */
class News_model extends Model {
function get_recent_stories() {
$query = $this->db->get('news_entries');
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $row;
}
}
}
?>
<?php
/* my controller */
class Site extends Controller {
function news() {
$this->load->model('news_model');
$data['site_title'] = 'News';
$data['stories'] = $this->news_model->get_recent_stories();
$this->load->view('news_view', $data);
}
}
?>
<?php
/* my view */
//html rubbish...
<?php echo $site_title;
foreach ($stories as $r):
echo $r->title;
echo $r->body;
endforeach ?>
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment