Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (27 sloc) 686 Bytes
<?
if (!defined("POUET_API")) exit();
$terms = split_search_terms( $_GET["q"] );
if ($terms)
{
$s = new BM_Query("parties");
$s->AddField("p.c as prods");
$s->AddJoin("left","(select party, count(*) as c from prods group by party) as p","p.party = parties.id");
$s->AddOrder(sprintf_esc("if(parties.name='%s',1,2)",$_GET["what"]));
$s->AddOrder("parties.name ASC");
$s->SetLimit(100);
foreach($terms as $term)
$s->AddWhere(sprintf_esc("parties.name LIKE '%%%s%%'",_like($term)));
$parties = $s->perform();
}
$result = new stdClass();
if ($parties)
{
$result->success = true;
$result->results = $parties;
}
else
{
$result->error = true;
}
output($result);
?>
You can’t perform that action at this time.