本帖最后由 筱戈 于 2014-12-16 11:40 编辑
错误提示:
A PHP Error was encounteredSeverity: Notice
Message: Undefined property: Article:: $verify
Filename: admin/article.php
Line Number: 26
Fatal error: Call to a member function run() on a non-object in E:\htdocs\icms\app\controllers\admin\article.php on line 26
PHP复制代码
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Article extends CI_Controller {
public function __construct () {
parent ::__construct ();
$this->load->model('category_model', 'cate');
$this->load->model('article_model', 'post');
}
public function index (){
$this->load->view('admin/post_list.html');
}
public function add (){
$data['category'] = $this->cate->fetch();
$this->load->helper('form');
$this->load->view('admin/post_add.html', $data);
}
public function save (){
$this->load->library('form_validation', 'verify');
$status = $this->verify->run('article');
if ($status) {
$data = array(
'title' => $this->input->post('title'),
'cid' => $this->input->post('category'),
'date' => $this->input->post('date'),
'keyword' => $this->input->post('keyword'),
'description' => $this->input->post('description'),
'excerpt' => $this->input->post('excerpt'),
'thumbnail' => $this->input->post('thumbnail'),
'password' => $this->input->post('password'),
'content' => $this->input->post('content')
);
$this->post->add($data);
success ('admin/article', '添加文章成功');
} else {
$this->load->helper('form');
$this->load->view('admin/post_add.html');
}
}
} 复制代码
为什么 $this->load->library('form_validation', 'verify'); 这个会加载失败?还有如果将 $this->load->model('category_model', 'cate'); 放在 add() 函数里也会出现下面的提示:
A PHP Error was encounteredSeverity: Notice
Message: Undefined property: Article:: $cate
Filename: admin/article.php
Line Number: 19
Fatal error: Call to a member function fetch() on a non-object in E:\htdocs\icms\app\controllers\admin\article.php on line 19
为什么$this->load->model('category_model', 'cate'); 这个也会加载失败?
|