Php 如何从Codeigniter中的控制器传递模型中的数组数据

Php 如何从Codeigniter中的控制器传递模型中的数组数据,php,codeigniter,Php,Codeigniter,致命错误:未捕获ArgumentCounter错误:参数太少,无法 函数Articlesmodel::update_article(),已传递0 这是我的型号 articlesmodel.php 这是我的控制器 admin.php 在您的模型中,您接受2个参数,但您不从控制器发送它们。只需将控制器的2个参数发送到模型,即可正常工作 在型号中 在控制器中 最后我解决了我的问题。问题出在,$post我无法在下面的$post=$this->input->post()下的函数中传递this变量 修复错误

致命错误:未捕获ArgumentCounter错误:参数太少,无法 函数Articlesmodel::update_article(),已传递0

这是我的型号

articlesmodel.php 这是我的控制器

admin.php
在您的模型中,您接受2个参数,但您不从控制器发送它们。只需将控制器的2个参数发送到模型,即可正常工作

在型号中

在控制器中


最后我解决了我的问题。问题出在,$post我无法在下面的
$post=$this->input->post()下的函数中传递this变量

修复错误后,代码为。

function update_article(){
                       print_r($this->input->post());
                       $this->load->model('articlesmodel');
                       $post=$this->input->post();
                      $update_articles=$this->articlesmodel->update_article($article_id,$post);
                       if($update_articles){

                       }
                   }
我没有在Controller中清除$post,也没有在Controller
$update\u articles

$update\u articles=$this->articlesmodel->update\u article($article\u id,$post)

$update_articles=$this->articlesmodel->update_article()之前


希望这将帮助您更新文章($article\u id,Array$article)

接受两个参数。您编写了
update\u article()
,它提供了0个参数。为什么这么难理解?像这样传递
$article\u id
$article
$update\u articles=$this->articlesmodel->update\u article($article\u id,$article)
function update_article(){
    print_r($this->input->post());
    $this->load->model('articlesmodel');
    $update_articles=$this->articlesmodel->update_article();
    if($update_articles){

    }
}
update_article($article_id,Array $article)
update_article($MISSING,$MISSING)
`

**before fixing  error the was problem here**

`function update_article(){
        print_r($this->input->post());
        $this->load->model('articlesmodel');
        $update_articles=$this->articlesmodel->update_article();
        if($update_articles){

        }

}`
function update_article(){
                       print_r($this->input->post());
                       $this->load->model('articlesmodel');
                       $post=$this->input->post();
                      $update_articles=$this->articlesmodel->update_article($article_id,$post);
                       if($update_articles){

                       }
                   }
function update_article($article_id,$article){

        $this->db->trans_start();
        $this->db->where('id', $article_id);
        $this->db->update('articles', $article);
        $this->db->trans_complete();
        return TRUE;
}