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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

how to get an id to start query?

Go to End



Community Member, 173 Posts

25 August 2009 at 3:01am


for the else-tree below i want to get all data from "Referenz" joining "Stammdaten". But the result should be limited to the first hit of "Stammdaten.Firmenname" with a match in "Referenz". How can i get the id from a first statement like:

$id = DataObject::get("Stammdaten", "", "Stammdaten.Firmenname", "LEFT JOIN Referenz ON Referenz.Kunde = Stammdaten.ID", "");

to pass it to the second query? Something like $id->ID?????

Thanks for your help.


function getReferenzenVonFirmen() {
// Debug::show(@Director::urlParam('ID')); die();
$id = @Director::urlParam('ID');
// Debug::show($id); die;
if($id > NULL) {
$Referenzen = DataObject::get("Referenz", "Referenz.Anzeigen = 1 AND BildEinsID > 0 AND StammdatenID = ".$id."", "StammdatenID", "", "");
} else {
$Referenzen = DataObject::get("Referenz", "Referenz.Anzeigen = 1 AND BildEinsID > 0", "Stammdaten.Firmenname", "LEFT JOIN Stammdaten ON Referenz.StammdatenID = Stammdaten.ID", "");
//Debug::show($Referenzen); die;
return $Referenzen;