CodeIgniter Forums
Select with result an object 2 dimension - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Select with result an object 2 dimension (/showthread.php?tid=63663)



Select with result an object 2 dimension - nofpowells - 11-24-2015

Hello guys, here my select and i'ts work fine


PHP Code:
$this->db->select('v.id, titulo, numero_vagas, c.sigla AS "sigla_curso", ci.nome as cidade, u.sigla');
 
$this->db->from("vagas v");
 
$this->db->join('cursos_vagas cv''v.id = cv.vagas_id');
 
$this->db->join('cursos c''c.id = cv.cursos_id');
 
$this->db->join('empresas e''e.id = v.empresas_id');
 
$this->db->join('cidade ci''ci.id = e.cidade_id');
 
$this->db->join('uf u''u.id = ci.uf_id');
 
$this->db->where('v.aprovado=''false'); 

and here my object result

array (size=1)
 'vagasNaoAprovadas' =>
   array (size=3)
     0 =>
       object(stdClass)[24]
         public 'id' => string '7' (length=1)
         public 'titulo' => string 'Programador c#' (length=14)
         public 'numero_vagas' => string '1' (length=1)
         public 'sigla_curso' => string 'ADS' (length=3)
         public 'cidade' => string 'campos do jordão' (length=17)
         public 'sigla' => string 'SP' (length=2)
     1 =>
       object(stdClass)[25]
         public 'id' => string '7' (length=1)
         public 'titulo' => string 'Programador c#' (length=14)
         public 'numero_vagas' => string '1' (length=1)
         public 'sigla_curso' => string 'TECIN' (length=5)
         public 'cidade' => string 'campos do jordão' (length=17)
         public 'sigla' => string 'SP' (length=2)
     2 =>
       object(stdClass)[26]
         public 'id' => string '8' (length=1)
         public 'titulo' => string 'Eventos' (length=7)
         public 'numero_vagas' => string '2' (length=1)
         public 'sigla_curso' => string 'TECEV' (length=5)
         public 'cidade' => string 'campos do jordão' (length=17)
         public 'sigla' => string 'SP' (length=2)

Blue line is my problem.
I need join all result in line blue where the title is the same (line Green).

Like object below.


array (size=1)
 'vagasNaoAprovadas' =>
   array (size=2)
     0 =>
       object(stdClass)[25]
         public 'id' => string '7' (length=1)
         public 'titulo' => string 'Programador c#' (length=14)
         public 'numero_vagas' => string '1' (length=1)
         public 'sigla_curso' =>
                                        object(stdClass)[1]
                                                   string 'ADS' (length=3)
                                        object(stdClass)[2]
                                                   string 'TECIN' (length=5)

         public 'cidade' => string 'campos do jordão' (length=17)
         public 'sigla' => string 'SP' (length=2)
     1 =>
       object(stdClass)[26]
         public 'id' => string '8' (length=1)
         public 'titulo' => string 'Eventos' (length=7)
         public 'numero_vagas' => string '2' (length=1)
         public 'sigla_curso' => string 'TECEV' (length=5)
         public 'cidade' => string 'campos do jordão' (length=17)
         public 'sigla' => string 'SP' (length=2)

Thanks and sorry for my bad english!