includeRowCount() public method

The default behavior is to NOT include a row count.
public includeRowCount ( ) : this
return this Query, marked to return total row count when run.
 private function testResponseMetadata()
 {
     $requestSample = 10;
     $query = new FactualQuery();
     $query->search("Sushi");
     $query->limit($requestSample);
     $query->includeRowCount();
     $res = $this->factual->fetch($this->testTables['global'], $query);
     // Get URL request string
     if (strlen($res->getRequest()) > 5) {
         $this->msg("Response URL", true);
     } else {
         $this->msg("Response URL", false);
     }
     // Get the table name queried
     if ($res->getTable() == $this->testTables['global']) {
         $this->msg("Request Table Name", true);
     } else {
         $this->msg("Request Table Name", false);
     }
     // Get http headers returned by Factual
     if (count($res->getHeaders()) > 2) {
         $this->msg("Response Headers", true);
     } else {
         $this->msg("Response Headers", false);
     }
     // Get http status code returned by Factual
     if ($res->getCode() > 0) {
         $this->msg("Response Code", true);
     } else {
         $this->msg("Response Code", false);
     }
     // Get total row count returned by Factual
     if ($res->getRowCount() > 0) {
         $this->msg("Total Row Count", true);
     } else {
         $this->msg("Total Row Count", false);
     }
 }
Beispiel #2
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;
    $totRows = count($data);
    /** search result counts */
    print "<div class=\"placecounts\">showing " . number_format($firstRow) . " through " . number_format($lastRow) . " of " . number_format($res->getTotalRowCount()) . " rows:</div>\r\n";