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?
> 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.
> -- > 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-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> I think transaction handling would be done inside JTable, not in the model.
> Rouven
> On 18.08.2012, at 01:09, Evandromar Machado <evandroma...@gmail.com<javascript:>> > wrote:
> 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.
> -- > 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<javascript:>
> .
> To unsubscribe from this group, send email to > joomla-dev-general+unsubscribe@googlegroups.com <javascript:>.
> For more options, visit this group at > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> Hello, thanks for your reply but I would like some examples of using these resources.
> Em sexta-feira, 17 de agosto de 2012 20h32min30s UTC-3, Rouven Weßling escreveu:
> I think transaction handling would be done inside JTable, not in the model.
> Rouven
> On 18.08.2012, at 01:09, Evandromar Machado <evandroma...@gmail.com> wrote:
>> 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.
>> -- >> 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-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> -- > 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/-/reLfMCLQB8wJ.
> To post to this group, send an email to joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.