title: retrieving data from two tables into multidimensional array api json response
body: <p>I am learning Api development where i want to retrieve data from two tables </p>
  
  <p>First table (items) contains:</p>
  
  <pre><code>id, feed_id, title, author, content
  </code></pre>
  
  <p>Second table (feeds):</p>
  
  <pre><code>feed_id,title,url
  </code></pre>
  
  <p>I want to get Json response like:</p>
  
  <pre><code> {
        - stories :
              [
                 id
                 feed_id {
                            title,
                            url
                         }
                 title
                 author
              ]
  }
  </code></pre>
  
  <p>My PHP function to retrieve story biased on id is like:</p>
  
  <pre><code>$app-&gt;get('/stories/:id', 'authenticate', function($story_id) { 
      $response = array();
      $result = Database::get('db')-&gt;table('items')
      -&gt;eq('rowid', $story_id)
      -&gt;findOne();
      //$response["error"] = false;
      if ($result != NULL) {
      $response['stories'] = array(
          'id' =&gt; $result["id"],
          'feed_id' =&gt; $result["feed_id"],
          'title' =&gt;  $result["title"],
          'isBreaking' =&gt; $result['isBreaking'],
          'author' =&gt; $result['author'],
          'updated' =&gt; $result["updated"],
          'url' =&gt; $result['url'],
          'content' =&gt; $result["content"]);
           echoRespnse(200, $response);
      }
      else {
          $response["error"] = true;
          $response["message"] = "The requested resource doesn't exists";
          echoRespnse(404, $response);
      } 
  });
  </code></pre>
  
  <p>The result i get is like:</p>
  
  <pre><code> {
     - "stories": [
               {
                  id
                  feed_id
                  title
                  url
               }
             ]
  }
  </code></pre>
  
  <p>How can i retrieve data from the second tablet (feeds) biased on feed_id and get the data into sub array?</p>