hi,
I have this sample code in my system:
<?php
$table1 = new table1();
$table1->name($name);
$table2 = new table2();
$table2->setStuff($stuff);
$conn = $this->di->get('my_connection');
$conn->begin();
$success = true;
if ($success){
if (!$table1->save()) {
$success = false;
}
}
if ($success){
if (!$table2->save()) {
$success = false;
}
}
if ($success){
$conn->commit();
} else {
$conn->rollback();
}
I force a error in table2 for test the system and rollback, but the table1 is created in tem database.
Why?
In the rollback, should not undo the save?
what the correct way to do?
sorry for my english