DataObject Transactions
| From: | Ed Greenberg | Date: | Wed, 19 Jan 2005 15:49:35 +0000 |
| Subject: | DataObject Transactions | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17020@lists.php.net to get a copy of this message | ||
Back in September, 2004, there was a discussion of transactions in DB_DataObject. From that I extrapolated this example:
---
$errors = 0;
$person = DB_DataObject::factory('person');
$person->query('BEGIN');
$mom = DB_DataObject::factory('mom');
$mom->name = 'Mary';
$mom_id = $mom->insert();
if (!$mom_id) $errors++;
$person->name = 'Fred';
$person->mom_id = $mom_id;
$res = $person->insert();
if (!$res) $errors++;
if ($errors == 0) $person->query('COMMIT');
else $person->query('ROLLBACK');
---
I note that we have two objects, $person and $mom.
Where do I call BEGIN, COMMIT and ROLLBACK? On $person? on $mom? on either?
I am using MySQL 4
Thanks,
</edg>