title: [Silverstripe 2.4]: How to get records containing columns from one-to-many relationship?
body: <p>there are two dataobject classes "A" and "B" having one-to-many relationship. I want to get data containing columns from both parent and child dataobject. How to achieve this in Silverstripe 's ORM or SQL Query. </p>
  
  <p>Example: Dataobject "A" has two events and first event contain one date info(start and end date). Second event contains two dates info (start and end date). </p>
  
  <p>I want to query database to get information containing columns from both "A" and "B" and it should shows 3 row as result. one from "A" and two from "B". </p>
  
  <p>I am using Silverstripe 2.4. A Movie Can have multiple dates to show. Movie dataobject has one-to-many relationship with MovieDate dataobject. I want to get all columns from Movie repeating each record of MovieDate associated with it. That means if movie has two dates, then I want to get two records</p>
  
  <pre><code>Title   Desc   StartDate   EndDate
  -----   ----   ---------   -------
  Matrix  AAA    2012-09-20  2012-09-20
  Matrix  AAA    2012-09-29  2012-09-29
  </code></pre>
  
  <p>Here is code for your kind consideration</p>
  
  <pre><code>&lt;?php
  class Movie extends DataObject
  {
   public static $db = array(
      'Title'    =&gt; 'Varchar',
      'Desc'     =&gt; 'Text',
   );
  
   public static $defaults = array(
        'RedirectionType' =&gt; 'Internal',
   );
  
   public static $has_one = array(
        'Image'         =&gt; 'Image',
        'Parent'        =&gt; 'Page',
        "LinkTo"        =&gt; "SiteTree"
   );
  
  public static $has_many = array(
        'MovieDates'     =&gt; 'MovieDate'
   );
  
   static $summary_fields = array(
      'Title'      =&gt; 'Movie Title',
      'Desc'       =&gt; 'Movie Description'
   );
  
   function getRequirementsForPopup() {
  
        Requirements::customCSS("
          .iframe_wrap {
                  top: 35%;
              }
        ");
  
   }
  
   public function getCMSFields()
   {
      $fields = new FieldSet(new TabSet('Root', $tab1 =  new Tab('Main')));
  
      $fields-&gt;addFieldsToTab('Root.Main', new TextField('Title', 'Movie Title'));
      $fields-&gt;addFieldsToTab('Root.Main', new TextareaField('Desc', 'Movie Description'));
  
      $tablefield = new DataObjectManager(
          $this,
          'MovieDates',
          'MovieDate',
          array('MovieStartDate' =&gt; 'Movie Start', 'MovieEndDate' =&gt; 'Movie End')
       );
  
  
      $tablefield-&gt;setPopupWidth(900);
      $tablefield-&gt;setAddTitle("Movie Date/Time");
      $fields-&gt;addFieldsToTab('Root.Main', $tablefield);
      $fields-&gt;addFieldsToTab('Root.Main', new LiteralField("Space", "&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;") );
      return $fields;
   }
  
  }
  
      &lt;?php
  class MovieDate extends DataObject{
  static $db = array(
      'MovieStartDate'             =&gt; 'Datetime',
      'MovieEndDate'               =&gt; 'Datetime',
  );
  
  static $has_one = array(
      'Movie' =&gt; 'Movie'
  );
  
  function getCMSFields(){
  
          $fields = new FieldSet();
  
          $movieStartDate = new DateField('MovieStartDate', 'Movie Start');
          $movieStartDate-&gt;setConfig('showcalendar', true);
          $fields-&gt;push($movieStartDate);
  
          $movieEndDate = new DateField('MovieEndDate', 'Movie End');
          $movieEndDate-&gt;setConfig('showcalendar', true);
          $fields-&gt;push($movieEndDate);
  
          $space = new LiteralField("Space", "&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;");
          $fields-&gt;push($space);
  
      return $fields;
  }
  
  }
  </code></pre>