Hi 
 
I am building a transactional sistem with mysql/innodb tables i would like to 
make sure my steps are rigth, i am using php on the webserver to manipulate 
these mysql tables.
 
-------------------------------------------------------------------------------
Also i try to use select ... read commited to get the accurate data but it do 
not work this syntax is rigth: SELECT Field FROM TABLE READ COMMITED
-------------------------------------------------------------------------------
basically i am doing:
<?
  /*******************************************
   START TRANSACTION  
  */
  $conn->execute("SET AUTOCOMMIT=0");
  $conn->begin();

 /*******************************************
  COMITT TRANSACTION  
 */
 if($conn->error()){
 
    $conn->rollback();

 } else {
   
  $conn->commit();

 }
-------------------------------------------------------------------------------
The entire code:
 
<?
  /*******************************************
   COMEÇA TRANSAÇÂO  
  */
  $conn->execute("SET AUTOCOMMIT=0");
  $conn->begin();
  
  $conn->execute("DELETE FROM Table_1 WHERE Field_1=".$Field_1_final." AND 
Field_2='".getParam("f_Field_2")."'");  
  
  $conn->execute($sqlChain->getSQL()); 
  $sqlNormal->setAction("UPDATE");  
  
  $conn->execute($sqlNormal->getSQL());    
  
  
  if( $id_security-_atual && ( !getParam("f_security") ) ) {
   $sqlDelSecurity->setAction("INSERT");  
   $conn->execute($sqlDelSecurity->getSQL());
  } 
 } else { // inclusão
  
  /*******************************************
   START TRANSACTION  
  */
  $conn->begin();
  
  $sql->setAction("INSERT");
  $conn->execute($sqlNormal->getSQL());
  $conn->execute($sqlChain->getSQL());  
  
 } 
 if(!$id_current_security) {      
  if( getParam("f_security") ) {
   $sqlSecurity->setAction("INSERT");
   $conn->execute($sqlSecurity->getSQL()); 
  }
 }
 /*******************************************
  COMITT TRANSACTION  
 */
 if($conn->error()){
  $conn->rollback();
 } else {
  $conn->commit();
 }
?>
 
i would like to know if anything is wrong is this the way a transaction must be 
handled ....
 
Thank´s in advance
 
 
 
 
 

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/ 

Reply via email to