I am creating a Sencha-Touch 2 application, and I have some problems with recovering my data from the server side (mysql DB).
Here is my data model:
Table1 : ID:int description:varchar(100) Table2 : ID:int description:varchar(100) table1_ID:int Table3 : ID:int name:varchar(100) info:varchar(100) table2_ID:int
Table 1 is connected to table 2 with a one-to-many relationship, and also between table 2 and table 3.
What I want from the server is a nested JSON that looks like this:
[ Table1_object1_ID: 'id' : { Table1_object1_description: 'description', Table2_Objects : [ 'Table2_object1': { Table2_object1_id : 'id', Table2_object1_description : 'description' Table3_Objects : [ table3_object1: { Table3_object1_name : 'name', Table3_object1_info : 'info', }, table3_object2: { Table3_object2_name : 'name', Table3_object2_info : 'info', }, table3_object3: { Table3_object3_name : 'name', Table3_object3_info : 'info', }, etc... ], }, 'Table2_object2': { Table2_object2_id : 'id', Table2_object2_description : 'description' Table3_Objects : [ ... ] }, etc.... ] }, Table1_object2_ID: 'id' : { etc.... ]
In my application, I use 3 Models for each table, and ideally I want to save my data in 3 stores, but this will be a different problem; -)
The first store (based on the model from Table1 ) executes a JsonP request to get the embedded JSON.
Actually my SQL query in a PHP file is simple:
SELECT * FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.table1_ID INNER JOIN Table3 ON Table2.ID = Table3.table2_ID;
I tried to create an array in PHP from my SQL results, but could not get the wait result. I am also trying to change my SQL using GROUP BY and GROUP_CONCAT , but here, I cannot get JSON.
Some help would be really appreciated.