Пример #1
0
  function LoadFromDB()
  {
    $s = new BM_query("lists");
    $s->AddField("lists.id");
    $s->AddField("lists.name");
    $s->AddField("lists.desc");
    $s->AddField("lists.addedDate");
    $s->Attach(array("lists"=>"addedUser"),array("users as addedUser"=>"id"));
    $s->Attach(array("lists"=>"upkeeper"),array("users as upkeeper"=>"id"));
    $s->AddWhere(sprintf_esc("lists.id=%d",$this->id));
    list($this->list) = $s->perform();

    $s = new BM_query("listitems");
    $s->Attach(array("listitems"=>"itemid"),array("prods as prod"=>"id"));
    $s->AddWhere(sprintf_esc("listitems.list=%d",$this->id));
    $s->AddWhere("listitems.type='prod'");
    $this->prods = $s->perform();

    $a = array();
    foreach($this->prods as $p) $a[] = &$p->prod;
    PouetCollectPlatforms($a);

    $s = new BM_query("listitems");
    $s->Attach(array("listitems"=>"itemid"),array("groups as group"=>"id"));
    $s->AddWhere(sprintf_esc("listitems.list=%d",$this->id));
    $s->AddWhere("listitems.type='group'");
    $this->groups = $s->perform();

    $s = new BM_query("listitems");
    $s->Attach(array("listitems"=>"itemid"),array("parties as party"=>"id"));
    $s->AddWhere(sprintf_esc("listitems.list=%d",$this->id));
    $s->AddWhere("listitems.type='party'");
    $this->parties = $s->perform();

    $s = new BM_query("listitems");
    $s->Attach(array("listitems"=>"itemid"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("listitems.list=%d",$this->id));
    $s->AddWhere("listitems.type='user'");
    $this->users = $s->perform();


  }