7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Getting an ID to bass into get_by_id
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 227 Views |
-
Getting an ID to bass into get_by_id

21 October 2011 at 4:30am
Hi
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?
Thanks
-
Re: Getting an ID to bass into get_by_id

22 October 2011 at 6:38am
What's the + for in your where clause?
-
Re: Getting an ID to bass into get_by_id

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
Cheers
| 227 Views | ||
|
Page:
1
|
Go to Top |

