function Load() { $s = new BM_query("parties"); if ($this->letter=="#") $s->AddWhere(sprintf("name regexp '^[^a-z]'")); else $s->AddWhere(sprintf("name like '%s%%'",$this->letter)); $s->AddOrder("name"); $this->parties = $s->perform(); if ($this->parties) { $ids = array(); foreach($this->parties as $group) $ids[] = $group->id; $idstr = implode(",",$ids); $rows = SQLLib::selectRows(sprintf("SELECT count(*) as c, party, party_year FROM `prods` WHERE party in (%s) GROUP by party, party_year order by party_year",$idstr)); $this->partyyears = array(); foreach($rows as $row) if ($row->party) $this->partyyears[$row->party][$row->party_year] = $row->c; $rows = SQLLib::selectRows(sprintf("SELECT * FROM `partylinks` WHERE party in (%s)",$idstr)); $this->partylinks = array(); foreach($rows as $row) if ($row->party) $this->partylinks[$row->party][$row->year] = $row; } }
function LoadFromDB() { $s = new BM_query(); $s->AddField("message"); $s->AddField("addedDate"); $s->AddTable("oneliner"); $s->attach(array("oneliner"=>"who"),array("users as user"=>"id")); //$s->AddOrder("oneliner.addedDate desc, oneliner.id desc"); $s->AddOrder("oneliner.id desc"); $s->SetLimit(POUET_CACHE_MAX); $this->data = $s->perform(); $this->data = array_reverse($this->data); }
function LoadFromDB() { $s = new SQLSelect(); $perPage = get_setting("bbsbbstopics"); $this->page = (int)max( 1, (int)$_GET["page"] ); $s = new BM_query(); $s->AddField("bbs_topics.id as id"); $s->AddField("bbs_topics.lastpost as lastpost"); $s->AddField("bbs_topics.firstpost as firstpost"); $s->AddField("bbs_topics.topic as topic"); $s->AddField("bbs_topics.count as count"); $s->AddField("bbs_topics.category as category"); $s->AddTable("bbs_topics"); $s->attach(array("bbs_topics"=>"userfirstpost"),array("users as firstuser"=>"id")); $s->attach(array("bbs_topics"=>"userlastpost"),array("users as lastuser"=>"id")); $dir = "DESC"; if ($_GET["reverse"]) $dir = "ASC"; switch($_GET["order"]) { case "firstpost": $s->AddOrder("bbs_topics.firstpost ".$dir); break; case "userfirstpost": $s->AddOrder("bbs_topics_firstuser.nickname ".$dir); break; case "userlastpost": $s->AddOrder("bbs_topics_lastuser.nickname ".$dir); break; case "topic": $s->AddOrder("bbs_topics.topic ".$dir); break; case "category": $s->AddOrder("bbs_topics.category ".$dir); break; case "count": $s->AddOrder("bbs_topics.count ".$dir); break; case "lastpost": default: $s->AddOrder("bbs_topics.lastpost ".$dir); break; } $s->AddOrder("bbs_topics.lastpost ".$dir); $s->SetLimit( $perPage, (int)(($this->page - 1) * $perPage) ); if ($_GET["category"]) $s->AddWhere(sprintf_esc("category='%s'",$_GET["category"])); //echo $s->GetQuery(); $this->topics = $s->performWithCalcRows( $this->count ); //PouetCollectPlatforms($this->prods); //$this->maxtopics = SQLLib::SelectRow("SELECT MAX(views) as m FROM prods")->m; }
function LoadFromDB() { $s = new BM_query(); $s->AddField("bbs_topics.id as id"); $s->AddField("bbs_topics.topic as topic"); $s->AddField("bbs_topics.count as count"); $s->AddField("bbs_topics.category as category"); $s->AddField("bbs_topics.lastpost as lastpost"); $s->AddField("bbs_topics.closed as closed"); $s->AddTable("bbs_topics"); $s->attach(array("bbs_topics"=>"userfirstpost"),array("users as firstuser"=>"id")); $s->attach(array("bbs_topics"=>"userlastpost"),array("users as lastuser"=>"id")); $s->AddOrder("lastpost desc"); $s->SetLimit(POUET_CACHE_MAX); $this->data = $s->perform(); }
function Load() { $s = new BM_query("boards"); $s->AddField("boards.id"); $s->AddField("boards.sysop"); $s->AddField("boards.name"); $s->AddField("boards.phonenumber"); if ($this->letter=="#") $s->AddWhere(sprintf_esc("name regexp '^[^a-z]'")); else $s->AddWhere(sprintf_esc("name like '%s%%'",$this->letter)); $s->AddOrder("name"); $this->boards = $s->perform(); /* if ($this->groups) { $ids = array(); foreach($this->groups as $group) $ids[] = $group->id; $idstr = implode(",",$ids); $prods = SQLLib::selectRows(sprintf("select id,name,type,group1,group2,group3 from prods where (group1 in (%s)) or (group2 in (%s)) or (group3 in (%s))",$idstr,$idstr,$idstr)); foreach($prods as $prod) { if ($prod->group1) $this->prods[$prod->group1][$prod->id] = $prod; if ($prod->group2) $this->prods[$prod->group2][$prod->id] = $prod; if ($prod->group3) $this->prods[$prod->group3][$prod->id] = $prod; } }*/ }
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(); }
function Load() { $s = new BM_query("groups"); if ($this->letter=="#") $s->AddWhere(sprintf("name regexp '^[^a-z]'")); else $s->AddWhere(sprintf("name like '%s%%'",$this->letter)); $s->AddOrder("name"); $this->groups = $s->perform(); if ($this->groups) { $ids = array(); foreach($this->groups as $group) $ids[] = $group->id; $idstr = implode(",",$ids); for ($x = 1; $x <= 3; $x++) { $counts = SQLLib::selectRows(sprintf("select group".$x." as groupID, count(*) as c from prods where group".$x." in (%s) group by group".$x."",$idstr)); foreach($counts as $count) { $this->prods[$count->groupID] += $count->c; } } } }