Forums / Developer / Transaction in php script?
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
Wednesday 26 July 2006 4:31:43 am
This seems to work:
$db =& eZDB::instance();$db->begin();
.. .. your code here..
$db->commit();
Ćukasz Serwatka
Wednesday 26 July 2006 4:32:27 am
Hi Igor,
Using eZ publish 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