Jump to:

3373 Posts in 999 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Combining two DataObject

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

Page: 1 2
Go to End
Author Topic: 3936 Views
  • pbenoit
    Avatar
    Community Member
    9 Posts

    Re: Combining two DataObject Link to this post

    Just want to say thanks! This thread helped me through merging two child pages into one 'holder page', appreciate the info.

  • merrick_sd
    Avatar
    Community Member
    88 Posts

    Re: Combining two DataObject Link to this post

    Can anyone help. I would like to limit my results.

    $numlimit = 10;
    $numlimit = $this->LatestDocCount;

    $ds = new DataObjectSet();

    $ds->merge(DataObject::get("SiteTree", "ClassName = 'Download' AND Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR ClassName = 'Download' AND LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "Created DESC, LastEdited DESC", ""));

    $ds->merge(DataObject::get("DocumentResource", "Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "PageID, Created DESC, LastEdited DESC", ""));

    $ds->sort('LastEdited', 'DESC' );

    return $ds

    SOLUTION this worked for me

    public function LatestDocuments() {

    $numlimit = 10;
    $numlimit = $this->LatestDocCount;

    $ds = new DataObjectSet();

    $ds->merge(DataObject::get("SiteTree", "ClassName = 'Download' AND Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR ClassName = 'Download' AND LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "Created DESC, LastEdited DESC", ""));

    $ds->merge(DataObject::get("DocumentResource", "Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "PageID, Created DESC, LastEdited DESC", ""));

    $ds->sort('LastEdited', 'DESC' );

    //getRange
    $records = $ds->getRange(0, $relimit);
    return $records
    }

    3936 Views
Page: 1 2
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.