00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00026 class DiogenesQuery {
00028 var $nArgs;
00030 var $sQuery;
00031
00034 function DiogenesQuery($sQue = "") {
00035 $this->sQuery = $sQue;
00036 $this->nArgs = 0;
00037 }
00038
00039
00042 function addArg($sArg, $sSep = "") {
00043 if ($sSep && $this->nArgs)
00044 $this->sQuery .= $sSep;
00045 $this->sQuery .= $sArg;
00046 $this->nArgs++;
00047 }
00048
00049
00053 function getPages($qcount,$hitmax=0)
00054 {
00055 if (!$hitmax)
00056 return array(array(0,$qcount));
00057
00058 $pages = array();
00059 $nrest = $qcount % $hitmax;
00060 $npages = ($qcount - $nrest) / $hitmax;
00061
00062
00063 for($i = 0; $i < $npages; $i++)
00064 array_push($pages, array($i*$hitmax, ($i+1)*$hitmax));
00065
00066
00067 if ($nrest)
00068 array_push($pages, array($npages*$hitmax, $npages*$hitmax+$nrest));
00069 return $pages;
00070 }
00071
00072
00075 function getResult(&$dbh,$hitmax=0,$start=0)
00076 {
00077 $query = $this->sQuery;
00078 if ($hitmax) {
00079 $query .= " LIMIT $start, $hitmax";
00080 }
00081
00082 return $dbh->query($query);
00083 }
00084
00085
00088 function getQuery() {
00089 return $this->sQuery;
00090 }
00091
00092 }
00093
00094 ?>