2
How do I add a variable or object within a json. It is thus printing my json:
{"Registros":[{"RegistroOperacaoID":"39","Tipo":"11","DataOperacao":"2019-03-27 16:29:36","AlunoID":null,"ResponsavelID":"57","CursoID":"327","MatriculaID":null,"PlanoID":"68","Processado":"0","Nome":null}
I would like to add together with this data another variable or object, that would be like this:
{"Registros":[{"RegistroOperacaoID":"39","Tipo":"11","DataOperacao":"2019-03-27 16:29:36","AlunoID":null,"ResponsavelID":"57","CursoID":"327","MatriculaID":null,"PlanoID":"68","Processado":"0","variavel":"1 registro","Nome":null}
my php code looks like this:
register.operacao.php
$sql = "SELECT R.RegistroOperacaoID, R.Tipo, R.DataOperacao, R.AlunoID, R.ResponsavelID, R.CursoID, R.MatriculaID, R.PlanoID, R.Processado, A.Nome FROM {$pfx}Registrooperacoes R LEFT JOIN {$pfx}Aluno A ON (A.AlunoID = R.AlunoID) WHERE Processado = 0";
    $qry = $database->query($sql);
    $listaOperacoes = array();
    $ctaOperacoes = 0;
    if($qry){
        while ($row = fetch($qry)) {
            $listaOperacoes[] = $row;            
            $ctaOperacoes++;           
        }
    }
    @$output = new StdClass();
    //$variavel = "$ctaOperacoes registros";        
    $output->Registros = $listaOperacoes;    
    $saida = json_encode($output, JSON_UNESCAPED_UNICODE);
    echo $saida;
Hello friend, it worked perfectly, thank you very much! perfect explanation.
– RevolveJr games
Thank you, a good way for you to help others with your question is to signal that this answer was the one that solved your problem.
– Lucas Emanuel