title: Zend Framework multi-step form generator
body: <p>I am working on a form generator for a multistep form submission.</p>
  
  <p>I have a steps table, each step has multiple groups, each group has multiple questions and finally each question has its own options, all of which are related to a program.</p>
  
  <p>I am building with zend framework.</p>
  
  <p>I created an sql statement in order to have the full result set as follows</p>
  
  <pre><code>$resultSet = $db-&gt;fetchAll($db-&gt;select()-&gt;from(array('rs' =&gt; 'registration_steps'))
     -&gt;joinInner(array('rg' =&gt; 'registration_groups'), 'rs.id = rg.registration_step_id')
     -&gt;joinInner(array('rq' =&gt; 'registration_questions'), 'rq.registration_group = rg.id')
     -&gt;joinInner(array('qo' =&gt; 'registration_question_options'), 'rq.id = qo.question_id', array('option_text'))
     -&gt;where('rs.program_id =?', $program_id)); 
  </code></pre>
  
  <p>The problem is obvious, i am getting duplicate results because am doing inner joins with the options.</p>
  
  <p>While this might work if i parse the whole thing on the client side, i want to find a more optimized or a better way of doing it.</p>