Unserialize data in CodeIgniter?

Posted on

Question :

Seeing that I have the following method:

Controller

public function get_objeto($permissao_id)
{
    if ($permissao_id == 0)
    {           
        $permissao_id = $permissao_id;
        $dados = $this->permissao->get($permissao_id);
        echo json_encode($dados, JSON_NUMERIC_CHECK);
    }
    else
    {
        $dados = $this->permissao->get_by_id($permissao_id);

        echo json_encode($dados, JSON_NUMERIC_CHECK);
    }
}

Model

// get_by_id
public function get_by_id($permissao_id)
{       
    $result = array();
    $result = $this->get_data($permissao_id);       
    return $result;
}
// get_data
public function get_data($permissao_id)
{
    $this->db->select('id, nome, permissoes tree_funcao, grupo_id');
    $this->db->from($this->tabela);
    $this->db->where('id',$permissao_id);
    $query = $this->db->get();
    $item = $query->row();      
    return $item;
}

And the following return from the database:

{"id":3,"nome":"teste","tree_funcao":"a:7:{i:0;a:9:{s:2:"id""

Answer :

s:1:""1""

s:4:""text""

s:9:""Dashboard""

s:4:""icon""

s:23:""fa fa-folder text-osun""

s:7:""li_attr""

O:8:""stdClass"":1:{s:2:""id""

s:1:""1""

}s:6:""a_attr""

Leave a Reply

Your email address will not be published. Required fields are marked *