Php 搜索模型::自动完成()缺少参数1,

Php 搜索模型::自动完成()缺少参数1,,php,ajax,codeigniter,Php,Ajax,Codeigniter,这是controller search.php public function login() { $email=$this->input->post('email'); $password=md5($this->input->post('password')); $result=$this->search_model->login($email,$password); if(!$result) { $th

这是controller search.php

public function login()
{
    $email=$this->input->post('email');
    $password=md5($this->input->post('password'));
    $result=$this->search_model->login($email,$password);   
    if(!$result) {
        $this->index();

    }

    else        {
        $this->session->set_userdata('user_id',$email);
        $seid=$this->session->userdata('user_id');
        $data['result'] =$this->search_model->autocomplete();              
        $this->load->view('pagination_view',array('result' => $result));    
    }

} 
========================================型号=========================================

public function autocomplete($like) {

    $this->db->select('name');
    $this->db->from('tbl_reg');
    $this->db->like('name', $like);
   // $this->db->where('status', ACTIVE);
    $q = $this->db->get();
    if ($q->num_rows() > 0) {
        return $q->result();
    }
}
在controller search.php中,
autocomplete()
中添加了什么参数。代码是

$data['result'] = $this->search_model->autocomplete();
我犯了这样一个错误:警告

消息:搜索\模型::自动完成()缺少参数1

还有另一个错误消息,如

Undefined variable: like

这个问题的解决方案是什么?

您需要在模型函数中传递参数

$this->search_model->autocomplete($YOUR_LIKE_VARIABLE);// pass your like variable here
因为在您使用的模型文件中

public function autocomplete($like) {

应该将like变量作为参数传递给模型函数

$this->search_model->autocomplete($YOUR_LIKE_VARIABLE);// pass your like variable here
在控制器中

$like = "matching word"; // replace this with your value;
$data['result'] =$this->search_model->autocomplete($like); 

如果您没有传递$like变量,那么您的模型将如何搜索

$like='any text' // this would be your keyword for which you are doing auto complete process, Like any name or anything.
$data['result'] = $this->search_model->autocomplete($like);

@Santy“YOUR_LIKE_变量”的意思是什么?希望在模型文件中传递LIKE的变量。我的意思是
$like
$like=“匹配单词”/用你的价值取代它$数据['result']=$this->search\u model->autocomplete($like);您需要通过单击checkmark@Amy将$like变量传递给ur$data['result']=$this->search_model->autocomplete();