Jump to:

23456 Posts in 18905 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » how to get an id to start query?

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

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

Page: 1
Go to End
Author Topic: 576 Views
  • dacar
    Avatar
    Community Member
    168 Posts

    how to get an id to start query? Link to this post

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

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