未捕获错误:在/opt/lampp/htdocs/epos/catalog/controller/prerecorded/preDemo.php:43中调用null上的成员函数preDemo1()堆栈跟踪:#0 / opt / lampp / htdocs / epos /system/engine/action.php(79):ControllerPrerecordedPreDemo-> insertData()#1 /opt/lampp/htdocs/epos/catalog/controller/startup/router.php(25):Action-> execute(Object) (注册表))#2 /opt/lampp/htdocs/epos/system/engine/action.php(79):ControllerStartupRouter-> index()#3 / opt / lampp / htdocs / epos / system / engine / router。 php(67):Action-> execute(Object(Registry))#4 /opt/lampp/htdocs/epos/system/engine/router.php(56):Router-> execute(Object(Action))# 5 /opt/lampp/htdocs/epos/system/framework.php(168):Router-> dispatch(Object(Action),Object(Action))#6 / opt / lampp / htdocs / epos / system / startup。 php(104):require_once(' / opt / lampp / htdo ...')#7 /opt/lampp/htdocs/epos/index.php(19):start(' catalog& #39;)在第43行的/opt/lampp/htdocs/epos/catalog/controller/prerecorded/preDemo.php中抛出#8 {main}
#Controllerpublic function insertData(){
// print_r($_POST);exit;
if($this->request->post['name'] && $this->request->post['email'] && $this->request->post['contactNumber'] && $this->request->post['businessType'] && $this->request->post['businessName'] && $this->request->post['role'] ) {
$data = array(
$name = $this->request->post['name'],
$email = $this->request->post['email'],
$contactNumber = $this->request->post['contactNumber'],
$businessType = $this->request->post['businessType'],
$businessName = $this->request->post['businessName'],
$role = $this->request->post['role']);
}
else {
$name = 0;
}
// echo "<pre>";print_r($data);
$this->load->model('prerecorded/preDemo');
$this->preDemo->preDemo1($data);
}
#Model ##########
<?php
class ModelPrerecordedPreDemo extends Model {
public function preDemo1($data) {
$this->db->insert("",$data);
}
}
答案 0 :(得分:0)
您的模型似乎存在命名问题。文件名与文件内的类匹配得很多。您也没有遵循CodeIgniter的文件命名约定。
模型文件preDemo.php
应该命名为Pre_demo.php
,并且可以像这样声明
class Pre_demo extends Model {
完成后,模型应该成功加载(显然不会在代码中加载)。
$this->load->model('prerecorded/pre_demo');
$this->pre_demo->preDemo1($data);
答案 1 :(得分:0)
正确的模型加载函数:
$this->prerecorded_preDemo->preDemo1($data);