CodeIgniter错误检索值

时间:2014-12-04 14:51:57

标签: php codeigniter

我正在尝试在CodeIgniter中填充表单。

我的模特:

  public function retrieve_where($id) {

        return $this->db->where('id', $id);
        $query = $this->db->get('funds');
        return $query->row();

    }

我的控制器:

public function edit($id) {

        $data['record'] = $this->funding_model->retrieve_where($id);


        $config = array(

            array(
                'field'=>"fn",
                'label'=>"Funder Name",
                'rules'=>'required'
            ),
            array(
                'field'=>"at",
                'label'=>"Award Type",
                'rules'=>'required'
            )

        );

        $this->form_validation->set_rules($config);

        if(!$this->form_validation->run($config)) {

            $this->load->view('header');
            $this->load->view('funding/edit', $data);
            $this->load->view('footer');

        }

我的观点的第一部分:

echo form_open('funding/add');

$fields = array(
    array("name"=>"on", "display_name" => "Opportunity Name"),
    array("name"=>"fn", "display_name" => "Funder Name", "value" => $record->funder_name),
    array("name"=>"cd", "display_name" => "Closing Date"),
    array("name"=>"di", "display_name" => "Deadline Info"),
    array("name"=>"at", "display_name" => "Award Type"),
    array("name"=>"ama", "display_name" => "Award Max"),
    array("name"=>"ami", "display_name" => "Award Min"),
    array("name"=>"budget", "display_name" => "Budget"),
    array("name"=>"summary", "display_name" => "Summary Info"),
    array("name"=>"website", "display_name" => "Website")
);

返回:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_DB_mysql_driver::$funder_name

Filename: funding/edit.php

Line Number: 14

我不明白这个问题,因为funder_name是我表资金中的一列。有什么想法吗?

1 个答案:

答案 0 :(得分:3)

return $this->db->where('id', $id);

你不需要退货;

$this->db->where('id', $id);