Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Getting an ID to bass into get_by_id

Go to End

3 Posts   619 Views


Community Member, 151 Posts

21 October 2011 at 4:30am


Let me start with my code

public static $belongs_to = array( 
            'Event' => 'Event',
            'Team' => 'Team'
        function getCMSFields() {
            $fields = parent::getCMSFields();
            $fields->removeFieldFromTab('Root.Content.Main', 'MenuTitle');
            $fields->removeFieldFromTab('Root.Content.Main', 'Title');
            $fields->removeFieldFromTab('Root.Content.Main', 'Content');
            $EventID = DataObject::get_by_id('Event',$this->EventID);
            $oData = (DataObject::get('Team','`Event_Teams`.EventID =' + $EventID,'','LEFT JOIN `Event_Teams` ON `Event_Teams`.TeamID=`Team`.ID ','')); 
            if ($oData) {
                $CategoriesSource = $oData->toDropDownMap('ID','Name'); 
            } else {
               // no categories there yet, might put a literalfield to tell the user  

What I am trying to do here is pass the EventID to the filter so I only see teams that are entered into the Event (by filter by eventID and then joining teams in the Event_teams table).

However I get an error that EventID is null... (or to that effect)... I am not sure how to correctly reference EventID so that I get the current event thats selected in the CMS...

Any ideas?



Forum Moderator, 4102 Posts

22 October 2011 at 6:38am

What's the + for in your where clause?


Community Member, 151 Posts

24 October 2011 at 9:09pm

disclaimer - im new to PHP, so i thought that would do the same as & in classic ASP... i didnt know how to include the variable in my select statement. So 2 probs here I guess...

1. How do I get the ID
2. How do i then include that in the where clause...

thanks for any help or where I can go to find the right answer :)