Problem when accessing query result in codeigniter

0

I make the following query:

$this->db->distinct();
$this->db->select('documentos.titulo_principal,documentos.descripcion,autores.nombre,areas.nombre');
$this->db->from('documentos');
$this->db->join('documento_area', 'documentos.id_documento = documento_area.id_documento');
$this->db->join('areas', 'areas.id_area = documento_area.id_area');
$this->db->join('documento_autor', 'documentos.id_documento = documento_autor.id_documento');
$this->db->join('autores', 'autores.id_autor = documento_autor.id_autor');
$this->db->join('documento_palabra', 'documentos.id_documento = documento_palabra.id_documento');
$this->db->join('palabraclave', 'palabraclave.id_palabra = documento_palabra.id_palabra');
$query = $this->db->get();

When visualizing its result is: stdClass Object ([main_title] => java bible [description] = & sdfdsfsdf [name] = > mathematics).

But when I do the direct query from sql, it brings me this data:

Someone knows how I can bring the result "JON" from the field "name". That result belongs to a table called "authors".

    
asked by John Vanegas 03.09.2017 в 08:39
source

1 answer

0

stdClass Object does not stop being an iterable object with attributes, you can not have two attributes with the same name since the last one overwrites the previous one. You could change the name of the column in one of the tables, or change the name during the query:

$this->db->select('
    documentos.titulo_principal,
    documentos.descripcion,
    autores.nombre,
    areas.nombre AS nombre_areas
');
    
answered by 03.09.2017 / 14:44
source