title: Symfony Doctrine - retrieve records from a related table using the foreign key field
body: <p>I have two related tables. One of the table has a one to many relationship to the second table. This is a sample illustration of the two tables</p>
  
  <p>**</p>
  
  <pre><code>registration
  id | firstname | membershipfk
  1  | John      | 2
  2  | Foo       | 3
  </code></pre>
  
  <p>**</p>
  
  <p>Here is illustration of the second table</p>
  
  <pre><code>membership
  id | type   | discount   | description     
  1  | Gold   | xyz        | xyz description
  2  | Silver | xyz        | xyz description
  </code></pre>
  
  <p>Now my present challenge is to retrieve the membership fields from the membership table using the foreign key in the registration table.
  For example: <code>Select Type, Discount and Description from Membership Entity where fk in registration entity is equal to 2</code></p>
  
  <p>Presently in my controller I am making this attempt</p>
  
  <pre><code>public function getMembersAction()
          {
            $restresults = $this-&gt;getDoctrine()-&gt;getRepository('XXXBundle:Members')-&gt;findAll();
  
            $data = array();
              foreach ($restresults as $restresult) {
  
                  array_push($data, $this-&gt;serializeData($restresult));
  
              }
  </code></pre>
  
  <p>Every kind assistance is much appreciated</p>