Hi

I am attempting to use innodb tables in mysql to handle some transactions my php/mysql system need to be reliable

How is it done with php and mysql ?

Supose i have these functions inside a class :
//----- begin transaction
function begin() {
mysql_query("BEGIN",$this->connect_id);
}

//----- commit transaction
function commit() {
	mysql_query("COMMIT",$this->connect_id);
}

//----- rollback transaction
function rollback() {
	mysql_query("ROLLBACK",$this->connect_id);
}

Do i need to set autocommit = 0 ? with php how can i do it?
mysql_query("set autocommit=0")?

How they are used to implement transactions on my system ?

Thank´s in advance

    12 days later

    Using innodb tables in mysql to implement a transactional php/mysql system is done just this way ?

    set autocommit=0

    begin

    commit or rollback

    Than the selects clauses must have the LOCK IN SHARE MODE clause at the final !

    And is that all?

    Anyone has any source code implementing a php/mysql transaction system ?

    thank´s in advance

      i have a class with these methods: commit(), rollback() and begin().

      So my code to make my transactional system with mysql/innodb tables is something like this, if anybody see an error in doing this way please let me know :

      $conn->execute("SET AUTOCOMMIT = 0");
      $conn->begin();

      $sql = "DELETE FROM table WHERE id IN (" . $bd_id . ")";
      $conn->execute($sql);
      $sql = "INSERT into table (data) values ('data')";
      $conn->execute($sql);

      if($conn->error()){
      $conn->rollback();
      } else {
      $conn->commit();
      }

        Write a Reply...