Group Array data when same php ID

0

I have an employee list array and they can have more than one linked code and for this I need to group in a list of type

FULANO - SECTOR - REDUCED CODE / REDUCED CODE

Doing a select I can not bring the information by a subconsulta de uma única linha retorna mais de uma linha

So I made a LEFT JOIN to bring all the information, but the names and ids are repeated for the reduced amount of code that that employee has.

The var_dump of the array looks like this.

 [1] => Array
        (
            [id] => 2
        [id_centris] => 84434
        [nome] => JOAO
        [ativo] => 0
        [cpf] => 704.116.620-15
        [codigo_reduzido] => 2
    )

[2] => Array
        (
            [id] => 1
        [id_centris] => 95876
        [nome] => BELTRANO
        [ativo] => 1
        [cpf] => 030.028.890-59
        [codigo_reduzido] => 566
    )

[3] => Array
        (
            [id] => 3
        [id_centris] => 67670
        [nome] => FULANO
        [ativo] => 1
        [cpf] => 828.769.080-34
        [codigo_reduzido] => 123456
    )

[4] => Array
        (
            [id] => 3
        [id_centris] => 67670
        [nome] => FULANO
        [ativo] => 1
        [cpf] => 828.769.080-34
        [codigo_reduzido] => 566
    )

If the center_id is the same, I need the_red_code to turn an array

Query

SELECT 
            F.ID_FUNCIONARIO    AS ID, 
            F.CODIGO_PESSOA_CENTRIS    AS ID_CENTRIS, 
            F.NOME AS NOME,
            F.CPF AS CPF,
            F.FLG_ATIVO AS ATIVO,
            CC.CODIGO_REDUZIDO
            --(SELECT CC.CODIGO_REDUZIDO FROM SCODBA.FUNCIONARIO_CENTRO_DE_CUSTO FC
              --INNER JOIN SCODBA.CENTRO_DE_CUSTOS CC ON FC.ID_CENTRO_CUSTO = CC.ID_CENTRO_CUSTO
              --WHERE FC.ID_FUNCIONARIO = F.ID_FUNCIONARIO)
                          FROM 
                            SCODBA.FUNCIONARIO F
              LEFT JOIN SCODBA.FUNCIONARIO_CENTRO_DE_CUSTO FCC ON FCC.ID_FUNCIONARIO = F.ID_FUNCIONARIO
              LEFT JOIN SCODBA.CENTRO_DE_CUSTOS CC ON FCC.ID_CENTRO_CUSTO = CC.ID_CENTRO_CUSTO
              WHERE FCC.FLG_ATIVO = 1                  
              ORDER BY F.NOME;
    
asked by anonymous 10.12.2018 / 21:16

0 answers