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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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


787 Views

Avatar
dacar

Community Member, 173 Posts

25 August 2009 at 3:01am

Hi,

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.

Code:

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;
}