There are 2 tables. The second depends on the first, that is, table1.id = table2.cat_id .
When I try to request one record of the first table and all the related records of the second table, I get confusion in the form:
array('id'=>'1', ..., 'servers'=>'server1'); array('id'=>'1', ..., 'servers'=>'server2'); Instead
array('id'=>'1', ..., 'servers'=>array([0]=>'server1', [1]=>'server2')); That is, the output needs one array with information from the first table with a nested array containing data from the second table.
This problem is solved by analyzing all the arrays and creating a new array with the necessary content, which is very inconvenient.
Tell me, please, how to solve this problem.
Request itself
SELECT c.id, c.name, c.class, s.name as servers FROM cat as c INNER JOIN servers as s ON s.cat_id = c.id WHERE c.id = '$id'
group_concatbys.name, and in the code to break this field into an array, but the option, let's say, is not very good - BOPOHgroup_concat(), but this is also not the case. That is, as I understand it, you cannot resolve this issue in the request, right? - mix