private function testQueryFilterLimitSort() { $limit = 10; $query = new FactualQuery(); $query->limit($limit); $query->sortAsc("name"); $query->field("region")->equal("CA"); try { $res = $this->factual->fetch($this->testTables['global'], $query); } catch (Exception $e) { $this->msg(__METHOD__, false, $e->getMessage()); } if ($res->getStatus() == "ok" && $res->getIncludedRowCount() == $limit) { $this->msg("Limit/Filter/Sort", true); } else { $this->msg("Limit/Filter/Sort", false); } }
/** * Reverse geocodes by returning a response containing the address nearest a given point. * @param obj point The point for which the nearest address is returned * @param string tableName Optional. The tablenae to geocode against. Currently only 'places' is supported. * @return the response of running a reverse geocode query for <tt>point</tt> against Factual. */ public function factualReverseGeocode($point, $tableName = "places") { $query = new FactualQuery(); $query->at($point); return new ReadResponse($this->request($this->urlForGeocode($tableName, $query))); }
/** default to first page */ 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 & 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;