php初学者,刚接触CI没多久,跟着那个20分钟视频学习一下,加了一个添加,修改等动作。在添加修改文章的时候,出现了问题。
控制器代码:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
$this->load->scaffolding('entries');
}
function index()
{
$data['title'] = "我的博客标题";
$data['heading'] = "我的博客头部";
$this->db->orderby("id", "desc");
$data['query'] = $this->db->get('entries');
$this->load->view('welcome_message',$data);
}
function comments()
{
$data['title'] = "我的评论";
$data['heading'] = "查看评论";
$this->db->where('entry_id',$this->uri->segment(3));
$data['query'] = $this->db->get('comments');
$this->load->view('comment_view',$data);
}
function comments_insert()
{
$this->db->insert('comments',$_POST);
redirect('welcome/comments/'.$_POST['entry_id']);
}
function article()
{
$data['title'] = "我的日志";
$data['heading'] = "添加文章";
$this->load->view('article',$data);
}
function article_add()
{
$this->db->insert('entries',$_POST);
redirect('welcome');
}
function article_del()
{
$this->db->where('id',$this->uri->segment(3));
$this->db->delete('entries');
redirect('welcome');
}
function update()
{
$data['title'] = "我的文章";
$data['heading'] = "修改文章";
$this->db->where('id',$this->uri->segment(3));
$data['query'] = $this->db->get('entries');
$this->load->view('update',$data);
}
function {
$this->db->where('id',$this->uri->segment(3));
$this->db->update('entries',$_POST);
redirect('welcome');
}
}
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
?>
其它方法都可以,就是article_up()不能实现。。。。。把$this->uri->segment(3)换成ID数字又可以。。。但同样方法在删除操作里又可以。
不知道为什么?
刚学没多久,大家不要见笑
|