Data not updated with DB Save

enzo.orsi 08 Jan, 2016
Hi,
I have a problem in updating DB.
The DB Save seems to be pretty ok, please find attached screenshot.

For example, the form data contains:

Array
(
    [id_risposta] => 65
    [F0050] => 
    [user_id] => 998
    [id] => 65
    [uniq_id] => ea45f53543df9708832c6bc7b88df8ff132f6298
    [form_id] => F0050
    [created] => 2015-11-14 23:07:03
    [modified] => 2016-01-08 19:53:30
    [id_prenotazione] => 0
    [R0001] => Persona fisica
    [R0002] => wfe
    [R0003] => 01-01-1970
    [R0004] => wef
    [R0005] => wef
    [R0006] => wef
    [R0007] => 234
    [R0008] => wef
    [R0009] => 23werfw
    [R0010] => 32


But unfortunately it is going to be updated only user_id and modified fields...

            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => UPDATE `AAAPDF_RISPOSTE_FORM` AS `Data` SET `user_id` = '998', `modified` = '2016-01-08 20:49:23' WHERE `id` = '65';
                        )

                )


Any idea?
GreyHead 09 Jan, 2016
Hi enzo.orsi,

Do the other columns exist in the table?

If you have made recent changes to the table or the form, please click the Delete Cache icon in the Forms Manager toolbar to update the table records ChronoForms is using.

Bob
enzo.orsi 09 Jan, 2016
Yes, all the fields exists in the table. The table is properly filled with a DB Save in INSERT mode.
But it does not work with this DB Save in UPDATE mode...

I tried again to Delete Cache, but nothing...

Any other idea?

It is in the attachment, in the submit event...

[[>>Later : removed attachment <<]]
enzo.orsi 09 Jan, 2016
Just to better explain the attachment: the DB Save under Submit / Riepilogo event should
- insert a new record in case ID does not exists (it works perfectly)
- update the record in case ID already exists (it does not work...)
GreyHead 09 Jan, 2016
Hi enzo.orsi,

I can't think of any obvious reason why the INSERT would work and the UPDATE doesn't. The form backup isn't helpful without the linked tables.

Please post the full debugger output in case there are any hidden clues there.

Bob
enzo.orsi 09 Jan, 2016
Here below the full debug.
As you can see, at the very bottom there is an UPDATE, but it updating only MODIFIED field, while all the other R0xxx fields are not updated...
But if the ID is not present in the table, it is properly inserted.


Data Array
Array
(
    [id_risposta] => 65
    [F0050] => 
    [amp;chronoform] => F0050
    [user_id] => 998
    [Data] => Array
        (
            [id] => 65
        )

    [id] => 65
    [uniq_id] => ea45f53543df9708832c6bc7b88df8ff132f6298
    [form_id] => F0050
    [created] => 2015-11-14 23:07:03
    [modified] => 2016-01-08 21:11:20
    [id_prenotazione] => 0
    [R0001] => Persona fisica
    [R0002] => wfe
    [R0003] => 01-01-1970
    [R0004] => wef
    [R0005] => wef
    [R0006] => wef
    [R0007] => 234
    [R0008] => wef
    [R0009] => 23werfw
    [R0010] => 32
    [R0011] => 01-01-1970
    [R0012] => 432
    [R0013] => 243
    [R0014] => La Sig.ra
    [R0015] => 234FFFFFFFFFFFFFFFFFFF
    [R0016] => 234
    [R0017] => zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
    [R0018] => 234
    [R0019] => 234
    [R0020] => 234
    [R0021] => 234
    [R0022] => è libero da ipoteche
    [R0023] => Persona giuridica
    [R0024] => 234
    [R0025] => 2%
    [R0026] => 234
    [R0027] => 765
    [R0028] => egr
    [R0029] => gtr
    [R0030] => rtg
    [R0031] => 25-08-2022
    [R0032] => rtg
    [R0033] => rgt
    [R0034] => 75
    [R0035] => rtg
    [R0036] => 
    [R0037] => 
    [R0038] => 
    [R0039] => 
    [R0040] => 
    [R0041] => 
    [R0042] => 
    [R0043] => 
    [R0044] => 
    [R0045] => rgt
    [R0046] => rtg
    [R0047] => rgt
    [R0048] => 43
    [R0049] => soggetto a ipoteca per un valore di €
    [R0050] => 345
    [R0051] => 345
    [R0052] => 5%
    [R0053] => 3%
    [R0054] => 14-01-2016
    [R0055] => 
    [R0056] => 
    [R0057] => 
    [R0058] => 
    [R0059] => 
    [R0060] => 34
    [R0061] => 19-11-2015
    [R0062] => 
    [R0063] => 
    [R0064] => 
    [R0065] => 
    [R0066] => 
    [R0067] => 
    [R0068] => 
    [R0069] => 
    [R0070] => 
[ here there are other fields...till R0200]
    [chronoform] => F0050
    [event] => submit
    [button1] => Prosegui
    [FormData] => Array
        (
            [form_id] => F0050
            [form_name] => Mandato a vendere
            [importo_form] => 0.01
            [pdf_contenuto] => <p align="center"><strong>Mandato a vendere</strong></p>
        )

    [source_url] => http://www.legalesemplice.it/crea-un-documento-legale/imprese/seleziona-il-tuo-settore/agenti-immobiliari/mandato-a-vendere
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [298] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `FormData`.`form_id` AS `FormData.form_id`, `FormData`.`form_name` AS `FormData.form_name`, `FormData`.`importo_form` AS `FormData.importo_form`, `FormData`.`pdf_contenuto` AS `FormData.pdf_contenuto`, `FormData`.`riepilogo_dati` AS `FormData.riepilogo_dati`, `FormData`.`advice` AS `FormData.advice`, `FormData`.`link_form` AS `FormData.link_form` FROM `AAAPDF_FORM` AS `FormData` WHERE `FormData`.`form_id` = 'F0050'
                        )

                )

        )

    [364] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => UPDATE `AAAPDF_RISPOSTE_FORM` AS `Data` SET `modified` = '2016-01-09 17:43:51' WHERE `id` = '65';
                        )

                )

        )

)
GreyHead 10 Jan, 2016
Hi enzo.orsi,

Sorry I can't work out what is happening. I've restored the form but it has a complex structure and without the tables is very hard to make any sense of. I can't even tell which DB Save isn not working.

I'd suggest that you try using a Custom Code action to save the data. Then you can add debug code to see exactly what Data is available to be saved.

Bob
enzo.orsi 14 Jan, 2016
Thanks Bob.
I am really trying with debut but I do not understand the problem...

Can I just kindly ask you a confirmation?
Does the attached DB save:
- insert the record in case ID is not existing
- update the record in case ID is already existing
?

All settings seems ok?
Thank you very much!
GreyHead 14 Jan, 2016
Hi enzo.orsi,

Yes

Bob
enzo.orsi 14 Jan, 2016
1 Likes
I discovered that DB Save is updating data contained under Model ID even if in DB Save "Save under Model ID" is set to "No".
I am lost...😟
GreyHead 14 Jan, 2016
Hi enzo.orsi,

What exactly is happening?

Bob
enzo.orsi 14 Jan, 2016
I found the problem...
There was an ID without Model and another ID inside Model, as shown in my previous debug:


Data Array
Array
(
    [Data] => Array
        (
            [id] => 65
        )

    [id] => 65


With this situation, DB Save was waiting for data contained inside Model even if "Save under Model ID" is set to "No".
Is it a bug?
Max_admin 14 Jan, 2016
Answer
So you have the "id" inside and outside the "Data" model, which means that an update will always occur regardless of the setting!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
enzo.orsi 14 Jan, 2016
No, it was not updating only data inside Model (only id was inside model)
Max_admin 16 Jan, 2016
Yes, that was a bug, thanks for pointing to it, I have fixed it for the next update!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.