3 * Copyright (C) 2003-2004 Polytechnique.org
4 * http://opensource.polytechnique.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * A class for describing database queries and breaking down the results
27 /** The number of arguments in the current query. */
29 /** The current query string. */
34 function DiogenesQuery($sQue = "") {
35 $this->sQuery
= $sQue;
40 /** Add an argument to the query.
42 function addArg($sArg, $sSep = "") {
43 if ($sSep && $this->nArgs
)
44 $this->sQuery
.= $sSep;
45 $this->sQuery
.= $sArg;
50 /** Return an array holding the start and end point
51 * for the pages holding the results.
53 function getPages($qcount,$hitmax=0)
56 return array(array(0,$qcount));
59 $nrest = $qcount %
$hitmax;
60 $npages = ($qcount - $nrest) / $hitmax;
63 for($i = 0; $i < $npages; $i++
)
64 array_push($pages, array($i*$hitmax, ($i+
1)*$hitmax));
68 array_push($pages, array($npages*$hitmax, $npages*$hitmax+
$nrest));
73 /** Execute the query and return the result.
75 function getResult(&$dbh,$hitmax=0,$start=0)
77 $query = $this->sQuery
;
79 $query .= " LIMIT $start, $hitmax";
82 return $dbh->query($query);
86 /** Accessor for the query string.