package search; sub new { bless {gernes=>[]}; } sub setUser { my $t=shift; $t->{user}=shift; } sub addGerne { my $t=shift; my $g=shift; push @{$t->{gernes}},$g; } sub setOrder { my $t=shift; } use project; use tmpl; sub showResult { my $t=shift; my %res; my $conds=0; if ($t->{user}) { my $it=&sql::select (qq( select p.mainkey, p.title from project p inner join membership m on m.project=p.mainkey where m.user = @{[&sql::str($t->{user})]} )); while (mt $r=$it->next) { bless $r,"project"; $res{$r->{mainkey}}=$r; $r->{condQualified}++; } $conds++; } if (@{[$t->{gernes}]}) { my @gs; for my $g (@{$t->{gernes}}) { push @gs, " g.gerne = ". &sql::i($g) ; } my $it=&sql::select (qq( select p.mainkey, p.title from project p inner join gerneset g on g.project=p.mainkey where @{[join(" or ",@gs)]} )); while (my $r=$it->next) { bless $r,"project"; $res{$r->{mainkey}}=$r if (! $res{$r->{mainkey}}); $r->{condQualified}++; } $conds++; } use table; my $tbl=new table; $tbl->setWrap(5); $tbl->addRow; for my $p (values %res) { if ($conds>= $p->{condQualified}) { $tbl->addCol($p->link2TopWithIcon); } } &tmpl::default("¸¡º÷·ë²Ì","result",$tbl->out); } 1;