phpmysqltransactions2phase-commit

Transaction Processing Using PHP and MySQL


I'm trying to implement two-phase commit using PHP and MySQL, and coming up short.

The main block I've found is that I'm unable to store the MySQL connection resource in a place where I can find it again for the second phase. Is it possible to serialize a database handle?

Here's the case I'm trying to code for:

  1. User sends data
  2. Server starts a MySQL transaction and executes some queries based on the data it has received.
  3. Server sends a file back to the user
  4. When the user has successfully received the file, the server commits its transaction. Otherwise it rolls it back.

This seems to require two HTTP Request/Response cycles, so I need to be able to re-connect to the same database handle in the second request in order to commit the transaction. I've been failing at this part.

Any advice is welcome, even if it's "this is not possible in PHP"


Solution

  • Take a look to LIXA Transaction Manager (http://lixa.sourceforge.net/) it integrates PHP and MySQL starting with release 0.9.0

    It provides Distributed Transaction Processing and two phase commit feature as well.

    Regards

    Ch. F.