|
本帖最后由 沦陷今生 于 2014-8-11 10:03 编辑
控制器代码PHP复制代码 public function update($id = 0) {
$data['title'] = $this->input->post('title', TRUE);
$data['content'] = $this->input->post('content', TRUE);//过滤post数据
$this->load->model('blog_m');
$this->blog_m->update($id, $data);//修改完成
$info['blog'] = $this->blog_m->get_blog_by_id($id);//重新取出数据
$html = $this->load->view('blog/view',$info,true);//把展现的前台代码保存
$this->load->helper('file');//生成
if(!write_file("blog/{$id}.html", $html))
{
$this->_message('修改失败!', 'blog/index', FALSE,'',1000);
}
else
{
$this->_message('修改成功!', 'blog/index', FALSE,'',1000);
}
} 复制代码
模型代码PHP复制代码
public function get_blog_by_id($id = 0)
{
return $this->db->where('id', $id)->get('blog')->row();
}
function update($id, $data)
{
return $this->db->where('id', $id)->update('blog', $data);
}
复制代码
视图模板文件
PHP复制代码 <?php
echo $blog->title?$blog->title:'';
echo "<br />\n";
echo $blog->content?$blog->content:'';
?> 复制代码
然后blog文件夹里面每次除了生成id.html还另外生成images.html和js.html
里面的代码内容是
HTML复制代码 <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered </h4>
<p>Severity: Notice </p>
<p>Message: Trying to get property of non-object </p>
<p>Filename: blog/view.php </p>
<p>Line Number: 4 </p>
</div><br />
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered </h4>
<p>Severity: Notice </p>
<p>Message: Trying to get property of non-object </p>
<p>Filename: blog/view.php </p>
<p>Line Number: 6 </p>
</div> 复制代码
请问怎么会多生成这个两个没指定的文件呢?怎么让它们不生成?谢谢各位
|
|