sQuery = $sQue; $this->nArgs = 0; } /** Add an argument to the query. */ function addArg($sArg, $sSep = "") { if ($sSep && $this->nArgs) $this->sQuery .= $sSep; $this->sQuery .= $sArg; $this->nArgs++; } /** Return an array holding the start and end point * for the pages holding the results. */ function getPages($qcount,$hitmax=0) { if (!$hitmax) return array(array(0,$qcount)); $pages = array(); $nrest = $qcount % $hitmax; $npages = ($qcount - $nrest) / $hitmax; // complete pages for($i = 0; $i < $npages; $i++) array_push($pages, array($i*$hitmax, ($i+1)*$hitmax)); // leftovers if ($nrest) array_push($pages, array($npages*$hitmax, $npages*$hitmax+$nrest)); return $pages; } /** Execute the query and return the result. */ function getResult(&$dbh,$hitmax=0,$start=0) { $query = $this->sQuery; if ($hitmax) { $query .= " LIMIT $start, $hitmax"; } return $dbh->query($query); } /** Accessor for the query string. */ function getQuery() { return $this->sQuery; } } ?>