title: Nested JSON from 3 one-to-many Tables
body: <p>I'm building a Sencha-Touch 2 app and I have some trouble with  the recuperation of my data from server side (mysql DB).</p>
  
  <p>Here's my data model : </p>
  
  <pre><code>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
  </code></pre>
  
  <p>Table1 is join to Table2 with a one-to-many relationship and same between Table2 and Table3.</p>
  
  <p>What I want from server is a nested JSON who looks like this : </p>
  
  <pre><code>[
     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....
  ]
  </code></pre>
  
  <p>In my App, I use 3 Models for each Table, and ideally I want to save my data in 3 Stores, but that will be an other problem ;-)</p>
  
  <p>The first Store (based on the Model from <code>Table1</code>) do a <code>JsonP</code> request to get the Nested JSON.</p>
  
  <p>Actually my SQL request in the PHP file is simple : </p>
  
  <pre><code>SELECT * 
  FROM Table1 
  INNER JOIN Table2 ON Table1.ID = Table2.table1_ID 
  INNER JOIN Table3 ON Table2.ID = Table3.table2_ID;
  </code></pre>
  
  <p>I tried to make an array in PHP from my SQL results but cannot get the expect result. 
  I also try to change my SQL with <code>GROUP BY</code> and <code>GROUP_CONCAT</code> but same here, cannot get the JSON I want.</p>
  
  <p>Some help would be really appreciate.</p>