Created
January 6, 2011 16:10
-
-
Save KyeRussell/768081 to your computer and use it in GitHub Desktop.
?
This file contains 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 | |
/* 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