Sets the maximum amount of records to return from this Query.
public limit ( $limit ) : this | ||
리턴 | this | Query |
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); } }
} /** 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; $lastRow = $firstRow + $res->getIncludedRowCount() - 1; $totRows = count($data); /** search result counts */