Forums

2 successive db save actions: second save action not executed

Erik66 23 Oct, 2014
Hello, I am trying to save the results of a Chronoforms 5 form to 2 different database tables using the db save action. Whatever I try, only the first db save action will work and the second one fails, consistently. Is this a known issue? I tried the server logs but no error info is output there regarding this issue. The Chonoforms debugger action also is non informative.The Joomla debugger and source code shows only one db save action is rendered by Chronoforms (the first) and the second one is completely empty.

Best regards from

Erik

Chronforms 5.0.2 / Joomla! 3.3.6
GreyHead 23 Oct, 2014
Hi Erik,

No known bug here. How do you have the second DB Save set up?

Bob

PS Please also see my reply to your other post as it may be the same problem here.
Erik66 23 Oct, 2014
Hello Bob,

the second db save setup is identical to the first, except that it saves to another table. I've made sure (in both cases) that all field names in the fomr correspond exactly to the field names in the db.

I tested wether it had to do with the order in which I saved to the tables, and I also tested wether they would save correctly individually with either of the save actions set to off. Individually, they save fine. Only when executed insuccession wil lthe the second save not take place. The debugger shows the second save action is completely omitted in the code in such cases. here's how it looks:
Debug Info

Array
(
    [20] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => UPDATE `xxxx_xx_xxxx` AS `Data` SET `link_name` = 'zzzz', `address` = '1', `postcode` = '2', `city` = '3', `telephone` = '4', `email` = '5@6.com', `link_desc` = '<p>wej we ryowe qw  pweuyw ew eppqew u pqwe qeup p w 9 ew y we</p>', `user_id` = '1165', `link_hits` = '0', `link_votes` = '0', `link_rating` = '0.000000', `link_featured` = '0', `link_published` = '1', `link_approved` = '1', `show_map` = '1', `lat` = '0.000000', `lng` = '0.000000', `alias` = '123', `zoom` = '13' WHERE `link_id` = '20';
                        )

                )

        )

    [23] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                        )

                )

        )

Best regards,

Erik

)
Max_admin 24 Oct, 2014
Please post the settings of the 2nd one.

What's the model id for the 2nd one ? if its also set to "Data" then please try to change it to something else, does this help ?

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
jpbhcom 16 Apr, 2015
While I cannot speak for the OP settings, I ran into the same issue, also using chronoforms v5. Attempting to save to two separate databases upon submit failed to save to the second table. Debug showed me that the second DB Save query was an UPDATE, using the id from the first DB Save query.

As suggested here, I attempted to adjust the "Model ID" for the 2nd DB Save, cleared cache, but no luck, the submission was still attempting to UPDATE the second table.

I also attempted to set "Save under Model ID" to Yes, but this produced an empty query.
I probably needed to set my fields up, something kind of like this?

$form->data['ModelID']['Fields'] = $form-data['Fields'];


HOWEVER, while researching to see what I was doing wrong, I found that Greyhead had answered a similar question:
http://www.chronoengine.com/forums/posts/f2/t90629.html

As per Greyheads suggestion, I found that an unset() in a Custom Code after the First DB Save, but before the Second fixed the issue.

<?php
unset($form->data['id']);
?>


Question, I didn't test the "Force save" setting in the DB Save, will this force the query to SET regardless of $form->data['cf_id']?

Thanks,
Jared
GreyHead 16 Apr, 2015
Hi Jared,

I haven't looked at the code behind the DB Save action but my understanding is that the Force Save will ignore any 'id' that may be in the form data and will create a new record.

Bob
This topic is locked and no more replies can be posted.