Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Request #9949 Transaction support
Submitted: 2007-01-25 20:28 UTC
From: doctor at wil dot linux dot krakow dot pl Assigned:
Status: Verified Package: DB_DataObject (version 1.8.5)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 27 - 10 = ?

 
 [2007-01-25 20:28 UTC] doctor at wil dot linux dot krakow dot pl
Description: ------------ Is it possible/reasonable to implement transactions support into DataObject instance ? Maybe something like startTransaction() endTransaction() methods ?

Comments

 [2007-01-26 02:25 UTC] alan_k (Alan Knowles)
$do->query("BEGIN"); $do->query("COMMIT"); $do->query("ROLLBACK"); are fully portable (as they use the DB abstraction backend.) Documentation might be a good idea... - feel free to send patches to the manual.
 [2008-01-30 19:55 UTC] tom057 (Lallement Thomas)
Operating system: Windows XP Package version: 1.8.7 PHP version: 5.2.1 Package: DB_DataObject Description: ------------ I use dataObject with the mdb2 mysqli driver and I noticed Transaction doesn't works. The problem comes from the fact a new connection is made on "factory", "get", "query" and "update" function ($this->_connect()) is called. In _connect() function, we have the following code: /* assumption is MDB2 */ require_once 'MDB2.php'; // this allows the setings of compatibility on MDB2 $db_options = PEAR::getStaticProperty('MDB2','options'); $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] = MDB2::connect($dsn,$db_options); But it would use a singleton to get the current connection in order to not create many connexion when a script as the one I write below (cf: Test script 1) is exectuted. So I suggere you to replace: $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] = MDB2::connect($dsn,$db_options); By: $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] = MDB2::singleton($dsn,$db_options); Moreover, if you look at the mysqli MDB2 driver, you will notice that when multiple connections are made, mdb2 option are not set correctly because there is a test on a static variable $already_checked in function _getServerCapabilities() and option are not set again if the variable have already been initialized. Test script 1: --------------- [in DB] NOM_JOURNALISTE = toto $journalistes_private = DB_DataObject::factory('JOURNALISTES'); $journalistes_private->get(17); $original_journalistes = clone($journalistes_private); $journalistes_private->NOM_JOURNALISTE = "tata"; $journalistes_private->query('BEGIN'); $journalistes_private->update($original_journalistes); $journalistes_private->query('ROLLBACK'); $journalistes_private->free(); Expected result: ---------------- [in DB] NOM_JOURNALISTE = toto Actual result: -------------- [in DB] NOM_JOURNALISTE = tata With the use of a singleton, I think it's more efficient and it works well !!
 [2008-02-27 06:14 UTC] alan_k (Alan Knowles)
added to todo...
 [2008-06-29 09:47 UTC] dufuz (Helgi Þormar Þorbjörnsson)
This is a feature not a bug, changing the status.