Hello folks, with very basic example will try to show what I need.
I need to create related records in other tables as possso use as a transaction commit and rollback quano receive an error during save.
EX 1: In the controller or any other place.
$contact = & JTable::getInstance ( 'Contact', 'PrefixTable' );
$contactdetails= & JTable::getInstance ( ' ContactDetail', ' PrefixTable ' );
if ($contact->store ()) {
if($contactdetails->store ()){
OK, contact and contact details saved successfully.
} else {
Error saving details such as rolling back the contact that was saved?
}
}
EX 2: Another way I like to do it in Model, i think more correct.
class PrefixModelContact extends JModelAdmin {
public function save($data) {
if (parent::save($data)) {
if($contactdetails->store ()){
OK, contact and contact details saved successfully.
} else {
Error saving details such as rolling back the contact that was saved?
}
}
}
}
Above are just examples, the actual code is much more elaborate.
I use transactionCommit transactionRollback With MYSQL and SQLSERVER or how to proceed?
Thank you all.