Fix bug when using multiple order bys in getSelectSQL. Fix ordering in reports list.
authorchriskl <chriskl>
Fri, 4 Nov 2005 04:19:41 +0000 (04:19 +0000)
committerchriskl <chriskl>
Fri, 4 Nov 2005 04:19:41 +0000 (04:19 +0000)
classes/Reports.php
classes/database/Postgres.php

index b6d12d9c7138e26686b7f9095a1953fa8b92444d..330ba5b82e367ab1263846681e3889278dccbfce 100644 (file)
@@ -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.14 2005/10/18 03:45:16 chriskl Exp $
+        * $Id: Reports.php,v 1.15 2005/11/04 04:19:41 chriskl Exp $
         */
 
        class Reports {
@@ -45,7 +45,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);
                }
index 7b5666e69d6e8b671b1ceba96af722614e3bbe36..7dfe0f42fcede4cc1060ea888b34d0c25da74751 100755 (executable)
@@ -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.277 2005/10/18 03:45:16 chriskl Exp $
+ * $Id: Postgres.php,v 1.278 2005/11/04 04:19:41 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -3823,7 +3823,7 @@ class Postgres extends ADODB_base {
         * @param $show An array of columns to show.  Empty array means all columns.
         * @param $values An array mapping columns to values
         * @param $ops An array of the operators to use
-        * @param $orderby (optional) An array of column numbers (one based) 
+        * @param $orderby (optional) An array of column numbers or names (one based) 
         *        mapped to sort direction (asc or desc or '' or null) to order by
         * @return The SQL query
         */
@@ -3888,7 +3888,10 @@ class Postgres extends ADODB_base {
                // ORDER BY
                if (is_array($orderby) && sizeof($orderby) > 0) {
                        $sql .= " ORDER BY ";
+                       $first = true;
                        foreach ($orderby as $k => $v) {
+                               if ($first) $first = false;
+                               else $sql .= ', ';
                                $sql .= $k;
                                if (strtoupper($v) == 'DESC') $sql .= " DESC";
                        }