【问题标题】:I am getting the following error: Codeigniter 3 too few arguments error我收到以下错误:Codeigniter 3 参数太少错误
【发布时间】:2022-12-13 14:12:06
【问题描述】:

您好,我正在尝试更新记录,但出现此错误:

“遇到了未捕获的异常 类型:ArgumentCountError 消息:函数 Complaints::update_workplace_incident() 的参数太少,0 已通过”

控制器功能

    public function update_workplace_incident($enquiry_id)
        {
    
            $response = array();
    
            if($enquiry_id) {
                $this->form_validation->set_rules('edit_practitioner', 'Practitioner', 'trim|required');
                $this->form_validation->set_error_delimiters('<p class="text-danger">','</p>');
    
                if ($this->form_validation->run() == TRUE) {
                    $data = array(
                        'practitioner' => $this->input->post('edit_practitioner'),
                    );
    
                    $update = $this->model_certification->update_workplace_incident($data, $enquiry_id);
                    if($update == true) {
                        echo "
                        <script> alert('Success')
                        window.location='https://kiruidavid.co.ke/osha/auth/login'
                        </script>";
                    }
                    else {
                        echo "
                        <script> alert('Failed')
                        window.location='https://kiruidavid.co.ke/osha/auth/login'
                        </script>";         
                    }
                }
                else {
                    $response['success'] = false;
                    foreach ($_POST as $key => $value) {
                        $response['messages'][$key] = form_error($key);
                    }
                }
            }

模型函数

    public function update_workplace_incident($data, $enquiry_id)
    {
        if($data && $enquiry_id) {
            $this->db->where('employer_complaint_id', $enquiry_id);
            $update = $this->db->update('company_complaints', $data);
            return ($update == true) ? true : false;
        }
    }

【问题讨论】:

    标签: php codeigniter-3


    【解决方案1】:

    让我们尝试在控制器函数的第一行添加 != null 由此 ...

    public function update_workplace_incident($enquiry_id)
    

    对这个...

    public function update_workplace_incident($enquiry_id != null)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 2019-12-12
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多