Пример #1
0
 private function testMultiCountry()
 {
     $requestSample = 10;
     $query = new FactualQuery();
     $query->search("Sushi");
     $query->field("country")->in(array("US", "CA"));
     $query->limit($requestSample);
     try {
         $res = $this->factual->fetch($this->testTables['global'], $query);
     } catch (Exception $e) {
         $this->msg(__METHOD__, false, $e->getMessage());
     }
     if ($res->size() !== $requestSample) {
         $this->msg("Multi Country Search", false);
     } else {
         $this->msg("Multi Country Search", true);
     }
 }
Пример #2
0
if (!$page || $page < 0) {
    $page = 0;
}
/** simple search interface */
print "<div id=\"searchcontent\">\r\n";
/** form */
print "<form class=\"searchform\" name=\"input\" action=\"./\" method=\"get\">\r\n";
print "<b>search</b> for <input class=\"search\" type=\"text\" value=\"" . $q . "\" name=\"q\"/> in ";
print "<b>postcode</b> <input class=\"postcode\" type=\"text\" value=\"" . $zip . "\" name=\"postcode\"/>";
print "<input type=\"submit\" value=\"search\">\r\n";
print "<input type=\"checkbox\" name=\"categories\" value=\"312,347\"" . $filter . "/>Only Search Restaurants &amp; Bars";
print "</form>\r\n";
try {
    /** make the query */
    $query = new FactualQuery();
    $query->search($q);
    $query->offset($page * PAGE_SIZE);
    $query->limit(PAGE_SIZE);
    $query->includeRowCount();
    $query->threshold("default");
    // see http://developer.factual.com/search-placerank-and-boost/#existence
    if ($zip) {
        $query->field("postcode")->equal($zip);
    }
    if ($cats) {
        $query->field("category_ids")->includesAny(explode(',', $cats));
    }
    $res = $factual->fetch("places-us", $query);
    $data = $res->getData();
    $firstRow = $page * PAGE_SIZE + 1;
    $lastRow = $firstRow + $res->getIncludedRowCount() - 1;