Retrieve data from stdClass Object

1

I use the codeigniter framework, I call from the view a selected data from a drop-down list in the following way:

$nombre_activo = $this->input->post('tipo_activo',true); 

With this data I consult the database so that it brings me the id of the selected name.

public function id_activo($nombre_activo)
    {
        $query=$this->db
                ->select("id_tipo_activo")
                ->from("tipo_activo")
                ->where(array("nombre_tipo_activo"=>$nombre_activo))
                ->get();
        //echo $this->db->last_query();exit;        
        return $query->row();            
    }

then in the controller I am calling what returns the query to me in the following way:

$id_activo = $this->activo_model->id_activo($nombre_activo);

I need to save the data obtained from the query in a variable type string, but what it is saving in the variable $ id_active is the following

  

stdClass Object ([id_type_type] = > 1)

How can I retrieve 1 of that std class?

I appreciate you can help me

    
asked by Daniel Suarez 11.11.2017 в 06:22
source

1 answer

1

stdClass Object as its class indicates it is an object so it can be treated as such, if you do this

$nombre_activo->id_tipo_activo

you will bring the value of said property

    
answered by 11.11.2017 / 07:30
source