Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » LEFT JOIN query

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 994 Views
  • JGC
    Community Member
    25 Posts

    LEFT JOIN query Link to this post

    Hi all

    I'm trying to get related data from two tables and output it into a TableListField which can then use the LightWindow to show more detailed information about rows and allow easy editing of them.

    I've been trawling through the documentation for the last couple of hours and I can't find anything useful in there. The TableListField article is promising, but its JOIN parameter is empty >_<

    Can anyone give me a hand, please?

       public function showCaseTable() {
          $resultSet = new DataObjectSet();
          $filter = '';
          $sort = "CaseTracker.ID ASC";
          $join = 'LEFT JOIN CaseTrackerStatus ON CaseTracker.Status = CaseTrackerStatus.ID';
          $instance = singleton('CaseTracker');      
          $query = $instance->buildSQL($filter, $sort, null, $join);
          $query->groupby[] = 'CaseTracker.ID';

          $trackerTable = new TableListField(
                'ID' => 'ID',
                'CaseName' => 'Name',
                'LastEdited' => 'Last updated',
                'CaseStatus' => 'Status'

             'LastEdited' => 'Date->Nice'


          // Generate fieldsets
          $fields = new FieldSet(
             new HiddenField('ID', 'ID'),

          $actions = new FieldSet(
             new FormAction('save', 'Update Cases')

          return new Form($this, "EditForm", $fields, $actions);


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.