Pman/Roo.php
[Pman.Base] / Pman / Roo.php
index 4472ca4..fdb362b 100644 (file)
@@ -51,8 +51,7 @@ class Pman_Roo extends Pman
     
     var $key; // used by update currenly to store primary key.
     
-    var $transObj = false ; // the transaction BEGIN / ROLLBACK / COMMIT Dataobject.
-    
+     
     var $max_limit = 10000;
     
     var $debugEnabled = true; // disable this for public versions of this code.
@@ -65,6 +64,7 @@ class Pman_Roo extends Pman
         if (!$au) {  
             $this->jerr("Not authenticated", array('authFailure' => true));
         }
+        if (!method_exists($au,'pid')) { print_r($au); } 
         if (!$au->pid()   ) { // not set up yet..
             $this->jerr("Not authenticated", array('authFailure' => true));
         }
@@ -166,7 +166,6 @@ class Pman_Roo extends Pman
      */
     function get($tab, $opts = Array())
     {
-        
          //  $this->jerr("Not authenticated", array('authFailure' => true));
        //echo '<PRE>';print_R($_GET);
       //DB_DataObject::debuglevel(1);
@@ -283,7 +282,7 @@ class Pman_Roo extends Pman
         $this->sessionState(0);
         $res = $x->find();
         $this->sessionState(1);
-        
+                
         if (false === $res) {
             $this->jerr($x->_lastError->toString());
             
@@ -642,7 +641,7 @@ class Pman_Roo extends Pman
         $this->init(); // for pman.
          
         $x = $this->dataObject($tab);
-        
+
         $this->transObj = clone($x);
         
         $this->transObj->query('BEGIN');
@@ -659,20 +658,21 @@ class Pman_Roo extends Pman
             // do we really delete stuff!?!?!?
             return $this->delete($x,$_REQUEST);
         } 
-         
+        
+        
+        
         
         $old = false;
         
         // not sure if this is a good idea here...
-        
+
         if (!empty($_REQUEST['_ids'])) {
             $ids = explode(',',$_REQUEST['_ids']);
             $x->whereAddIn($this->key, $ids, 'int');
             $ar = $x->fetchAll();
             
             foreach($ar as $x) {
-                $this->update($x, $_REQUEST);
-                
+                $this->update($x, $_REQUEST);  
             }
             // all done..
             $this->jok("UPDATED");
@@ -680,7 +680,7 @@ class Pman_Roo extends Pman
             
         }
          
-        if (!empty($_REQUEST[$this->key])) {
+        if (!empty($_REQUEST[$this->key])) { 
             // it's a create..
             if (!$x->get($this->key, $_REQUEST[$this->key]))  {
                 $this->jerr("Invalid request (id does not point to  a record.)");
@@ -691,7 +691,7 @@ class Pman_Roo extends Pman
             if (empty($_POST)) {
                 $this->jerr("No data recieved for inserting");
             }
-            
+
             $this->jok($this->insert($x, $_REQUEST));
             
         }
@@ -934,6 +934,7 @@ class Pman_Roo extends Pman
         }
         
         $res = $x->insert();
+
         if ($res === false) {
             $this->jerr($x->_lastError->toString());
         }
@@ -1065,7 +1066,7 @@ class Pman_Roo extends Pman
         //print_r($old);
         
         $cols = $x->tableColumns();
-        //print_r($cols);
+
         if (isset($cols['modified'])) {
             $x->modified = date('Y-m-d H:i:s');
         }
@@ -1122,11 +1123,13 @@ class Pman_Roo extends Pman
      */
     
     function delete($x, $req)
-    {
+    { 
         // do we really delete stuff!?!?!?
         if (empty($req['_delete'])) {
             $this->jerr("Delete Requested with no value");
         }
+        
+        
         // build a list of tables to queriy for dependant data..
         $map = $x->links();
         
@@ -1149,14 +1152,14 @@ class Pman_Roo extends Pman
        // echo '<PRE>';print_r($affects);exit;
        // DB_Dataobject::debugLevel(1);
        
-
+        
         
         
         $bits = array_map(function($v) { return (int)$v; } , explode(',', $req['_delete']));
         
         // let's assume it has a key!!!
         
-        $x->whereAdd($this->key .'  IN ('. implode(',', $bits) .')');var_dump($x); 
+        $x->whereAdd($this->key .'  IN ('. implode(',', $bits) .')');
         if (!$x->find()) {
             $this->jerr("Nothing found to delete");
         }
@@ -1195,7 +1198,8 @@ class Pman_Roo extends Pman
                     continue;
                 }          
             }
-   
+            
+            
             $has_beforeDelete = method_exists($xx, 'beforeDelete');
             // before delte = allows us to trash dependancies if needed..
             $match_total = 0;
@@ -1215,7 +1219,7 @@ class Pman_Roo extends Pman
                     if (!is_a($chk,'DB_DataObject') && !is_a($chk,'PDO_DataObject'))  {
                         $this->jerr('Unable to load referenced table, check the links config: ' .$ka[0]);
                     }
-                    $chk->{$ka[1]} =  $xx->{$this->key};                   
+                    $chk->{$ka[1]} =  $xx->{$this->key};
                     $matches = $chk->count();
                     $match_total += $matches;
                     if ($matches) {
@@ -1227,8 +1231,6 @@ class Pman_Roo extends Pman
                 
             }
             
-            //
-
             if (!empty($match_ar)) {
                 $chk = $match_ar[0];
                 $chk->limit(1);
@@ -1386,7 +1388,7 @@ class Pman_Roo extends Pman
         $q_filtered = array();
         
         $keys = $x->keys();
-        // var_dump($keys);exit;
+
         foreach($q as $key=>$val) {
             
             if (in_array($key,$keys) && !is_array($val)) {
@@ -1454,7 +1456,7 @@ class Pman_Roo extends Pman
                 
             }
             
-            
+                
             
             switch($key) {
                     
@@ -1564,34 +1566,8 @@ class Pman_Roo extends Pman
         
     }
     
-     
-    // our handlers to commit / rollback.
-    
       
     
-    function jok($str)
-    {
-        // note that commit will only work if an insert/update was done,
-        // so some stored proc calls may not have flagged this.
-        
-        if ($this->transObj ) {
-            $this->transObj->query( connection_aborted() ? 'ROLLBACK' :  'COMMIT');
-        }
-        return parent::jok($str);
-    }
-    
-    
-    function jerr($str, $errors=array(), $content_type = false)
-    {
-        // standard error reporting..
-        if ($this->transObj) {
-            $this->transObj->query('ROLLBACK');
-        }
-        return parent::jerr($str,$errors,$content_type);
-    
-    }
-    
-