【发布时间】:2017-10-21 04:36:47
【问题描述】:
这是我的控制器:
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('User_model');
$this->load->helper(array('form','text','url','array'));
$this->load->library(array('Form_validation','email','session'));
}
public function index()
{
$this->model->insert_item();
$this->load->view('welcome_message');
}
}
这是我的模型:
defined('BASEPATH') OR exit('No direct script access allowed');
class User_model extends CI_Model {
public function insert_item()
{
echo "hi";
}
}
当我调用模型函数但它没有加载它时显示错误致命错误:调用非对象上的成员函数 insert_item()
【问题讨论】:
-
记住,我们只使用模型来做数据库操作,
-
@Ukasyah - 这不是真的。您可以将模型用于任何数据处理情况(例如从 xml 或 json 检索数据)。
标签: php jquery html css codeigniter