Development

Changeset 7486

You must first sign up to be able to contribute.

Changeset 7486

Show
Ignore:
Timestamp:
02/14/08 17:20:15 (5 years ago)
Author:
Josh.Reynolds
Message:

added transactions for batch processing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfMDB2RestPlugin/trunk/lib/MDB2RestClient.class.php

    r7155 r7486  
    115115     
    116116    $this->_logToSymfony('Unserializing and returing...'); 
     117    $this->_logToSymfony($results); 
     118     
    117119    return unserialize($results); 
    118120  } 
     
    232234      if (isset($results['error'])) { 
    233235        throw new Exception($results['error']); 
     236      } elseif (isset($results['transaction_errors'])) { 
     237        throw new Exception(print_r($results['transaction_errors'])); 
    234238      } else { 
    235239        return $results; 
  • plugins/sfMDB2RestPlugin/trunk/lib/MDB2RestServer.class.php

    r5600 r7486  
    117117      $results = array('error' => $e->getMessage()); 
    118118    } 
    119  
     119     
     120     
    120121    return $results; 
    121122  } 
     
    129130  { 
    130131    $results = array(); 
     132     
     133    if ($this->mdb2->supports('transactions')) 
     134    { 
     135      $this->mdb2->beginTransaction(); 
     136    } 
     137     
    131138    foreach ($arguments as $request) { 
    132139      $results[] = $this->executeRequest($request); 
    133140    } 
    134  
     141     
     142    if ($this->mdb2->supports('transactions') && $this->mdb2->in_transaction) 
     143    { 
     144      $errors = array(); 
     145      $i = 0; 
     146      foreach($results as $r) 
     147      { 
     148        if(isset($r['error'])) 
     149        { 
     150           
     151          $errors[$i] = $r['error']; 
     152        } 
     153        $i++; 
     154      } 
     155      if(sizeof($errors) > 0) 
     156      { 
     157        $results['transaction_errors'] = $errors; 
     158        $this->mdb2->rollback(); 
     159      } 
     160      else 
     161      { 
     162        $this->mdb2->commit(); 
     163      } 
     164    } 
     165     
    135166    return $results; 
    136167  }