获取DB的特定字段的值

I'm trying to get a particular value of a field from the DB. But why i try to get the value it gives me the error:

Message: Undefined index: status_status_id

Part of my controller:

     function get_by_id($id = 0){


   $data['info'] = $this->Rfetch1_model->getdata_by_id($id);
   $r=$data['status_status_id'];

    if ($r==0){

         //something....
}

My model:

   function getdata_by_id($id = 0){
    $this->db->where('id',$id);

    $sql = $this->db->get('info');

    return $sql->result();
}

From my understanding my model will return everything from the 'info' table where id=$id; Then why it cannot get the value of the field status_status_id.

You will have to access it as:

$r=$data['info'][0]->status_status_id;

$sql->result() will return an array of row objects.

Alternatively, you could return $sql->row() from getdata_by_id() and then access it as:

$r=$data['info']->status_status_id;

check this

controller

function get_by_id($id = 0){


   $data['info'] = $this->Rfetch1_model->getdata_by_id($id);
   $r=$data['info']->status_status_id;

    if ($r==0){

         //something....
}

Model

function getdata_by_id($id = 0){
    $this->db->where('id',$id);

    $sql = $this->db->get('info');

    return $sql->row();
}