From 16d1eb48ce74e3d0858a9db89d67ce9b806faad6 Mon Sep 17 00:00:00 2001 From: chriskl Date: Fri, 4 Nov 2005 04:24:13 +0000 Subject: [PATCH] Fix bug when using multiple order bys in getSelectSQL. Fix ordering in reports list. --- classes/Reports.php | 4 ++-- classes/database/Postgres.php | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/classes/Reports.php b/classes/Reports.php index d3bfd231..70695d90 100644 --- a/classes/Reports.php +++ b/classes/Reports.php @@ -4,7 +4,7 @@ * the functions provided by the database driver exclusively, and hence * will work with any database without modification. * - * $Id: Reports.php,v 1.11.2.2 2005/10/18 03:15:57 chriskl Exp $ + * $Id: Reports.php,v 1.11.2.3 2005/11/04 04:24:13 chriskl Exp $ */ class Reports { @@ -44,7 +44,7 @@ $sql = $this->driver->getSelectSQL('ppa_reports', array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql'), - $filter, $ops, array(2 => 'asc')); + $filter, $ops, array('db_name' => 'asc', 'report_name' => 'asc')); return $this->driver->selectSet($sql); } diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index e5f12af3..9244a559 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres.php,v 1.250.2.7 2005/10/18 03:15:58 chriskl Exp $ + * $Id: Postgres.php,v 1.250.2.8 2005/11/04 04:24:13 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -3806,8 +3806,17 @@ class Postgres extends ADODB_base { // ORDER BY if (is_array($orderby) && sizeof($orderby) > 0) { $sql .= " ORDER BY "; + $first = true; foreach ($orderby as $k => $v) { - $sql .= $k; + if ($first) $first = false; + else $sql .= ', '; + if (ereg('^[0-9]+$', $k)) { + $sql .= $k; + } + else { + $this->fieldClean($k); + $sql .= '"' . $k . '"'; + } if (strtoupper($v) == 'DESC') $sql .= " DESC"; } } -- 2.39.5