white space
[Pman.Base] / Pman / Roo.php
index 4dfffb1..d7b1878 100644 (file)
@@ -260,8 +260,13 @@ class Pman_Roo extends Pman
           //DB_DataObject::debugLevel(1);
         // count with multiple joins and no conditions can be quite slow - so if there are no conditions - just remove the joins from the count.
         $xx = clone($x);
-        if (empty($xx->_query['condition']) && !empty($xx->_join)) {
+        $old_where = $x->whereAdd();
+        if (empty($old_where )) {
             $xx->_join = '';
+        } else {
+            $x->whereAdd($old_where);
+            $xx=clone($x);
+            
         }
        
         $total = $xx->count($this->countWhat);
@@ -764,12 +769,12 @@ class Pman_Roo extends Pman
                     $ms ? json_decode($ms) : false
             );
         }
+        
         if ($ms !== false) {
             return $this->multiSort($x);
         }
-        
         if ($sorted === false) {
-            
             $cols = $x->tableColumns();
             $excols = array_keys($this->cols);
             
@@ -911,7 +916,6 @@ class Pman_Roo extends Pman
         if (method_exists($x, 'toRooArray')) {
             $this->jok($x->toRooArray($req));
         }
-        
         $this->jok($x->toArray());
         
         
@@ -919,6 +923,7 @@ class Pman_Roo extends Pman
     
     function insert($x, $req, $with_perm_check = true)
     {
+        
         if (method_exists($x, 'setFromRoo')) {
             $res = $x->setFromRoo($req, $this);
             if (is_string($res)) {
@@ -927,7 +932,7 @@ class Pman_Roo extends Pman
         } else {
             $x->setFrom($req);
         }
-        
+
         if ( $with_perm_check &&  !$this->checkPerm($x,'A', $req))  {
             $this->jerr("PERMISSION DENIED (i)");
         }
@@ -981,7 +986,7 @@ class Pman_Roo extends Pman
         if ($ev) { 
             $ev->audit($x);
         }
-        
+      
         // note setFrom might handle this before hand...!??!
         if (!empty($_FILES) && method_exists($x, 'onUpload')) {
             $x->onUpload($this, $_REQUEST);