0

未捕获的错误:在 /opt/lampp/htdocs/epos/catalog/controller/prerecorded/preDemo.php:43 中调用成员函数 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(Registry)) # 2 /opt/lampp/htdocs/epos/system/engine/action.php(79): ControllerStartupRouter->index() #3 /opt/lampp/htdocs/epos/system/engine/router.php(67): 动作->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('/选择/lampp/htdo...') #7 /opt/lampp/htdocs/epos/index.php(19): start('catalog') #8 {main} 抛出 /opt/lampp/htdocs/epos/catalog/controller/prerecorded/preDemo.php在第 43 行

# 控制器
public 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);



    }
# 模型 ##########
<?php
class ModelPrerecordedPreDemo extends Model {
    public function preDemo1($data) {

        $this->db->insert("",$data);
    }
}
4

2 回答 2

0

来自模型的正确加载函数:

$this->prerecorded_preDemo->preDemo1($data);
于 2019-02-15T12:03:48.463 回答
0

您的模型似乎存在命名问题。文件名与文件内的类非常匹配。您也没有遵循 CodeIgniter 的文件命名约定。

模型文件preDemo.php可能应该这样命名Pre_demo.php和声明

class Pre_demo extends Model {

完成后,模型应该成功加载(它显然没有在您的代码中)。

$this->load->model('prerecorded/pre_demo');
$this->pre_demo->preDemo1($data);
于 2018-02-14T14:15:14.700 回答