JOMLA 2.5 transactionCommit and transactionRollback

116 views
Skip to first unread message

Evandromar Machado

unread,
Aug 17, 2012, 7:09:47 PM8/17/12
to joomla-de...@googlegroups.com
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.

Rouven Weßling

unread,
Aug 17, 2012, 7:32:30 PM8/17/12
to joomla-de...@googlegroups.com
I think transaction handling would be done inside JTable, not in the model.

Rouven

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/K5LUW3aUmUUJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Evandromar Machado

unread,
Aug 18, 2012, 7:09:15 PM8/18/12
to joomla-de...@googlegroups.com
Hello, thanks for your reply but I would like some examples of using these resources.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

Rouven Weßling

unread,
Aug 18, 2012, 7:12:06 PM8/18/12
to joomla-de...@googlegroups.com
Unfortunately neither the CMS nor the platform currently use transactions so I can't point you to any examples. Sorry.

Best regards
Rouven

To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/reLfMCLQB8wJ.

To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages