How to handle the return of a query in the PHP database

Asked

Viewed 48 times

1

I’m having a hard time creating the logic for handling/processing the data I receive from an SQL query in the database. My query is returning an array in the following format:

My array:

array = {0: (id =1, nome = fulano, id_categoria= 5 categoria="formulario de 
            teste") ;
1:(id =2, nome = ciclano, id_categoria= 3 categoria="formulario de registro");
2:(id =3, nome = beltrano, id_categoria= 3 categoria="formulario de teste")}

I would like to do the processing of this array to group the id and nome table 1 by category of table 2. My question is whether there is a way to convert this array into an object, or if there is some other way in PHP that I can access this data separately.

  • Why not change the query to the database to already bring the way you want? How is your current query?

  • change the fetch to suit what you need

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.