|
model
public function get_news($slug = FALSE){
if($slug === FALSE){
$query = $this->db->get('news');
return $query->result_array();
}
$query = $this->db->get_where('news',array('id'=>$id));
return $query->row_array();
}
controller
public function view($slug){
$data['news_item'] = $this->news_model->get_news($slug);
if(empty($data['news_item'])){
show_404();
}
$data['title'] = $data['news_item']['title'];
$this->load->view('block/header',$data);
$this->load->view('news/view',$data);
$this->load->view('block/foot',$data);
}
view
<?php
echo '<h2>'.$news_item['title'].'</h2>';
echo $news_item['text'];
?>
模型和模块里的 $slug 代表是什么
请各位大神回答 在下谢谢
|
|