Pman/Roo.php
[Pman.Base] / Pman / Roo.php
index d841e5f..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));
         }
@@ -282,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());
             
@@ -641,7 +641,7 @@ class Pman_Roo extends Pman
         $this->init(); // for pman.
          
         $x = $this->dataObject($tab);
-        
+
         $this->transObj = clone($x);
         
         $this->transObj->query('BEGIN');
@@ -658,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");
@@ -679,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.)");
@@ -690,7 +691,7 @@ class Pman_Roo extends Pman
             if (empty($_POST)) {
                 $this->jerr("No data recieved for inserting");
             }
-            
+
             $this->jok($this->insert($x, $_REQUEST));
             
         }
@@ -933,6 +934,7 @@ class Pman_Roo extends Pman
         }
         
         $res = $x->insert();
+
         if ($res === false) {
             $this->jerr($x->_lastError->toString());
         }
@@ -1064,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');
         }
@@ -1121,18 +1123,20 @@ 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();
         
         $affects  = array();
         
         $all_links = $x->databaseLinks();
-             
+        
         foreach($all_links as $tbl => $links) {
             foreach($links as $col => $totbl_col) {
                 $to = explode(':', $totbl_col);
@@ -1147,6 +1151,9 @@ 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']));
         
@@ -1189,14 +1196,14 @@ class Pman_Roo extends Pman
                     $chk->_match_key = $ka[1];
                     $match_ar[] = clone($chk);
                     continue;
-                }  
+                }          
             }
             
+            
             $has_beforeDelete = method_exists($xx, 'beforeDelete');
             // before delte = allows us to trash dependancies if needed..
             $match_total = 0;
-
+            
             if ( $has_beforeDelete ) {
                 if ($xx->beforeDelete($match_ar, $this) === false) {
                     $errs[] = "Delete failed ({$xx->id})\n".
@@ -1206,7 +1213,6 @@ class Pman_Roo extends Pman
                 // refetch affects..
                 
                 $match_ar = array();
-           
                 foreach($affects as $k=> $true) {
                     $ka = explode('.', $k);
                     $chk = DB_DataObject::factory($ka[0]);
@@ -1382,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)) {
@@ -1450,7 +1456,7 @@ class Pman_Roo extends Pman
                 
             }
             
-            
+                
             
             switch($key) {
                     
@@ -1560,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);
-    
-    }
-    
-