我想从我的模型中获取查询结果并在视图中使用它。我不知道为什么,但我的结果是空的。你能看看这个并告诉我我做错了吗?
控制器:
$peugeot = $this->input->post('peugeot');
$citroen = $this->input->post('Citroen C-Elysee');
$nissan= $this->input->post('Nissan Evalia');
$renault = $this->input->post('Renault Trafic 9-os');
$this->load->model('Edit_model');
$this->Edit_model->peugeot($peugeot);
if($peugeot)
{
$result = $this->Edit_model->peugeot($peugeot);
$data['result'] = $result;
}
型号:
public function peugeot($peugeot)
{
$this->db->like('model', $peugeot, 'after');
$query = $this->db->get('cars');
$result = $query->result();
return $result;
}
查看:
if($peugeot)
{
print_r($result);
}
答案 0 :(得分:0)
有点奇怪,但它有效
我已将控制器更改为
$data['peugeot'] = $this->input->post('peugeot');
$data['citroen'] = $this->input->post('citroen');
$data['nissan'] = $this->input->post('nissan');
$data['renault'] = $this->input->post('renault');
$this->load->model('Edit_model');
if($data['peugeot'])
{
$this->Edit_model->peugeot($data['peugeot']);
$result = $this->Edit_model->peugeot($data['peugeot']);
$data['result'] = $result;
$this->load->view('content/editprocess',$data);
}