How to select join multiple tables and get it in a nested array easily?
For Example
Table 1 -School: SchoolID, SchoolName,PrincipalID
Talbe 2 - Principal: PrincipalID,PrincipalName
I want to get a nested array in PHP like
"School": [
{
"SchoolID": "7",
"SchoolName": "New",
"Principal": {
"PrincipalID":"1",
"PrincipalName":"James"
}
}
The problem is, how to get the nested array use a automatic way instead of specifying each field and add it into a array manually? without even kowning the actual field names, just nesting multiple tables into a nested array.