pear::db, INNO DB and transactions
| From: | Demian Turner | Date: | Thu, 11 Dec 2003 15:53:14 +0000 |
| Subject: | pear::db, INNO DB and transactions | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-9474@lists.php.net to get a copy of this message | ||
this 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)) {
$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