phpPgAdmin History
------------------
+Version 3.0.0-dev-4
+-------------------
+
+* Sort on a column when browsing a table
+
Version 3.0.0-dev-3
-------------------
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.72 2003/04/08 12:51:44 chriskl Exp $
+ * $Id: Postgres.php,v 1.73 2003/04/14 04:42:27 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
/**
* Returns a recordset of all columns in a relation. Supports paging.
* @param $relation The name of a relation
+ * @param $sortkey Field over which to sort. '' for no sort.
* @param $page The page of the relation to retrieve
* @param $page_size The number of rows per page
* @param &$max_pages (return-by-ref) The max number of pages in the relation
* @return -2 counting error
* @return -3 page or page_size invalid
*/
- function &browseRelation($relation, $page, $page_size, &$max_pages) {
+ function &browseRelation($relation, $sortkey, $page, $page_size, &$max_pages) {
$oldrelation = $relation;
$this->fieldClean($relation);
return -3;
}
+ // Figure out ORDER BY
+ if ($sortkey != '') {
+ $this->fieldClean($sortkey);
+ $orderby = " ORDER BY \"{$sortkey}\"";
+ }
+ else $orderby = '';
+
// We need to do a check to see if the relation has an OID column. If so, then
// we need to include it in the result set, in case the user has created a primary key
// constraint on it.
// Actually retrieve the rows, with offset and limit
if ($hasID)
- $rs = $this->selectSet("SELECT \"{$this->id}\",* FROM \"{$relation}\" LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
+ $rs = $this->selectSet("SELECT \"{$this->id}\",* FROM \"{$relation}\" {$orderby}LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
else
- $rs = $this->selectSet("SELECT * FROM \"{$relation}\" LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
+ $rs = $this->selectSet("SELECT * FROM \"{$relation}\" {$orderby}LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
$status = $this->endTransaction();
if ($status != 0) {
/**
* List tables in a database
*
- * $Id: tables.php,v 1.11 2003/03/28 12:29:53 chriskl Exp $
+ * $Id: tables.php,v 1.12 2003/04/14 04:42:27 chriskl Exp $
*/
// Include application functions
$misc->printMsg($msg);
if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1;
+ if (!isset($_REQUEST['sortkey'])) $_REQUEST['sortkey'] = '';
// Retrieve page from table. $max_pages is returned by reference.
- $rs = &$localData->browseRelation($_REQUEST['table'], $_REQUEST['page'], $guiMaxRows, $max_pages);
+ $rs = &$localData->browseRelation($_REQUEST['table'], $_REQUEST['sortkey'], $_REQUEST['page'], $guiMaxRows, $max_pages);
// Fetch unique row identifier, if there is one
$key = $localData->getRowIdentifier($_REQUEST['table']);
reset($rs->f);
while(list($k, ) = each($rs->f)) {
if ($k == $localData->id && !$guiShowOIDs) continue;
- echo "<th class=data>", htmlspecialchars($k), "</th>";
+ echo "<th class=\"data\"><a href=\"{$PHP_SELF}?action=browse&page=", $_REQUEST['page'], "&{$misc->href}&sortkey=", urlencode($k), "&table=",
+ urlencode($_REQUEST['table']), "\">", htmlspecialchars($k), "</a></th>\n";
}
// @@ CHECK THAT KEY ACTUALLY IS IN THE RESULT SET...
while(list($k, $v) = each($rs->f)) {
if ($k == $localData->id && !$guiShowOIDs) continue;
elseif ($v == '') echo "<td class=\"data{$id}\"> </td>";
- else echo "<td class=data{$id}>", nl2br(htmlspecialchars($v)), "</td>";
+ else echo "<td class=\"data{$id}\">", nl2br(htmlspecialchars($v)), "</td>";
}
if (sizeof($key) > 0) {
$key_str = '';