|
楼主 |
发表于 2013-1-23 11:39:22
|
显示全部楼层
全文model,都是照着用户指南上的写的~~
PHP复制代码 <?php
class News_model extends CI_Model
{
public function __construct ()
{
$this->load->database();
}
//从数据库中读取数据
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('slug'=>$slug));
return $query->row_array();
}
public function set_news ()
{
$this->load->helper('url');
$slug = url_title ($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text')
);
return $this->db->insert('news', $data);
}
}
?> 复制代码 |
|