Re: pear::db, INNO DB and transactions
| From: | Demian Turner | Date: | Thu, 11 Dec 2003 16:03:21 +0000 |
| Subject: | Re: pear::db, INNO DB and transactions | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9476@lists.php.net to get a copy of this message | ||
agreed, i mention this because i'm about to hard-code a whole stack of transactions like
db->query('BEGIN');
db->query('COMMIT');
but it would be great to get the relevant PEAR::DB driver to do the work so the code could be portable to at least mssql and postgres, something in the project requirements.
cheers
demian
Joe Stump wrote:
Maybe the best way to do this (as I'm not sure innodb tables are shown in DESC tbl_name) would be to allow for a define DB_FORCE_TRANSACTIONS which can then be used by the transaction functions in the mysql driver. As per your question concerning transaction functions returning errors on unsupported DB's I think it is programmed that way for transparency purposes (though I agree at *least* a notice should be thrown by the mysql driver). --Joethis subject has probably been addressed before but i couldn't find it on MARC: some brief testing seems to show transactions called from PEAR::DB are not respected if the db is MySQL and the table type is INNO DB which supports transactions. calling from DataObject, i used the following code: $oUser = & new DataObjects_Usr(); $db = $oUser->getDatabaseConnection(); $db->autoCommit(false); // update user object [...] $successUser = $oUser->update(); // update user's contact details [...] $successContact = $oContact->update(); if (!($successUser && $successContact)) {-- Joe Stump <joe@joestump.net> http://www.joestump.net "Label makers are proof God wants Sys Admins to be happy."$db->rollback(); Base::raiseError('There was a problem inserting the record',SGL_ERROR_NOAFFECTEDROWS); } else {$db->commit(); Output::msgSet('details successfully updated'); Response::redirect('userMgr.php', array('action'=> 'list'));} however calling transaction related stuff directly in the queries works as expected: $db->query('BEGIN'); $db->query('COMMIT'); $db->query('ROLLBACK'); interestingly, no errors occur when the code is run on MyISAM tables. So the question is, are there plans for the MySQL driver to detect INNO DB tables and support them, is there an interest in this? cheers demian -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php