Forums / Developer / Transaction in php script?

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Transaction in php script?

Author Message

Igor Vrdoljak

Wednesday 26 July 2006 3:27:47 am

Hi

I am working on a eZ solution which includes creation, update and deletion of eZ objects through SOAP web service methods. I intend to create methods which insert/update/delete multiple objects within one method call, so I need to put all that work into a single database transaction.

I am using eZ version 3.7.5, MySQL 4.1 with all tables converted to InnoDB, and transactions enabled in site.ini. Also, I use NuSOAP extension for developing web services.

Is there a simple way to put my PHP code into a single transaction. Something like:

START TRANSACTION;
...
... insert/update/delete code here
...
COMMIT TRANSACTION;

Thanx in advance.

http://www.netgen.hr/eng
http://twitter.com/ivrdoljak

Igor Vrdoljak

Wednesday 26 July 2006 4:31:43 am

This seems to work:

$db =& eZDB::instance();
$db->begin();

..
.. your code here
..

$db->commit();

http://www.netgen.hr/eng
http://twitter.com/ivrdoljak

Łukasz Serwatka

Wednesday 26 July 2006 4:32:27 am

Hi Igor,

Using Exponential DB library (ezdb) you can use it like:

include_once( "lib/ezdb/classes/ezdb.php" );

$db =& eZDB::instance();
$db->begin();

//rest PHP code goes here

$db->commit();

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog