Pman/Roo.php
authorAlan Knowles <alan@akbkhome.com>
Thu, 11 Nov 2010 11:15:33 +0000 (19:15 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 11 Nov 2010 11:15:33 +0000 (19:15 +0800)
Pman/Roo.php

index 278d5de..82e054c 100644 (file)
@@ -667,13 +667,15 @@ class Pman_Roo extends Pman
         $do->selectAdd(); // we need thsi as normally it's only cleared by an empty selectAs call.
         
         $selectAs = array(array(  $xx , '%s'));
+        $this->countWhat = false;
         $has_distinct = false;
         if ($filter) {
             $cols = array();
            
             foreach($xx as $c) {
                 if ($distinct && $distinct == $c) {
-                    $has_distinct = 'DISTINCT( ' . $do->tableName() .'.'. $has_distinct .') as ' . $has_distinct ;
+                    $has_distinct = 'DISTINCT( ' . $do->tableName() .'.'. $c .') as ' . $c;
+                    $this->countWhat =  'DISTINCT  ' . $do->tableName() .'.'. $c .'';
                     continue;
                 }
                 if (in_array($c, $filter)) {
@@ -745,6 +747,10 @@ class Pman_Roo extends Pman
             
             
         }
+        
+        if ($has_distinct) {
+            $this->selectAdd($has_distinct);
+        }
         //DB_DataObject::debugLevel(1);
         // we do select as after everything else as we need to plop distinct at the beginning??
         /// well I assume..