简体   繁体   中英

controller doesn't return any value using codeigniter

I don't know whats wrong with my code, It doesn't return any data

Controller

function FundCluster(){
   $cluster=$this->input->post('funds');
   $this->load->model('Jev_model'); 
   $fund= $this->Jev_model->getFundCluster($cluster);
   $fundCluster= $fund['FundCluster'].$cluster;
   $this->insert_entry($fundCluster);

}

Model

function getFundCluster($cluster){
    $this->db->select('FundCluster');
    $this->db->from('fund');
    $this->db->where('id', $cluster); 
    $query = $this->db->get();

    return $query->result_array();

}

All i want is to get the value of this line

$fundCluster= $fund['FundCluster'].$cluster;

The purpose of this is to pass that variable to the other function

function insert_entry($fundcluster) {
$series=$fundcluster;
...
..
.
redirect('Jev/entryAccount/'.$series);
}

您可能必须使用。

 $fund[0]['FundCluster']

change this in model

return $query->result_array();

to

return $query->row();

in controller

$fundCluster= $fund['FundCluster'].$cluster;

to

$fundCluster= $fund->FundCluster;

Try to use

$query->row();

rather then

$query->result_array();

It will give you object and you can get value like

$fundCluster= $fund->FundCluster.$cluster;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM