开发者

using query results in the same function that calls them

For some reason I am unable to use query results in the same function that calls them. Please see controller below and model and let me know where my issue is.

What breaks down is line 2 of controller, trying to concatenate query result contact_name and description_computer and saving it as variable name. I get the following error "Undefined variable: query" for both query results.

Using codeigniter.

Controller

function get_quarter_info($data)
{
    $data['query'] = $this->model->get_client_info($da开发者_运维知识库ta);
    $data['name'] = $query['contact_name'] . " " . $query['description_computer'] . ".pdf";
    $html = $this->load->view('Quarter_info_view', $data, true);
    $pdf = pdf_create($html, '', false);
    write_file($data['name'], $pdf);
    $this->index();

}

Model

function get_client_info($data)
{
    $query = $this->db->get_where('subscriber_report', array('client_number'=> $data['client_number']));
    return $query->row_array();
}


You should probably use $query instead of $data['query]. The data array is used to pass data to your view.


You're not assigning a value to $query in get_quater_info. Instead, you're assigning the value to $data['query'];

Try this instead:

$query = $data['query'] = $this->model->get_client_info($data);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜