Forums

Does db save action perform UPDATE instead of INSERT INTO

Erik66 23 Oct, 2014
Hello,

I am trying to save the contents of a chronform to a db. The db fails to be written with the form's content is not written into the database if I try. Inspecting the Joomla! source code of the form, I find it perfoms a mysql UPDATE query instead of an INSERT INTO query. Is this expected behavior?

I solved the issue by INSERTing a record first using custom code so the form can actually UPDATE that record. But in previous versions of Chronoforms I did not have this issue and db save actions would work out of the box.

Best regards

Erik
GreyHead 23 Oct, 2014
Hi Erik,

Is the form in an article? If so please see this FAQ

Bob
Erik66 23 Oct, 2014
Hello Bob,

the form is in an article, yes, displayed using the plugin. So, I read the FAQ (many thanks for pointing that out) and only 1 issue ticked off. One of the fields in the form is a pulldown and I had forgotten to handle the array. Once that action added, the form would also save to the db. But, it still is saving using the UPDATE syntax and not using the INSERT INTO syntax. So, i left my workaround intact. Is that really necessary and shouldn't the form INSERT ?

Thank you and best regards,

Erik
Max_admin 24 Oct, 2014
Hi Erik,

The issue is that an "id" parameter is passed from the article URL to Chronoforms, which is the primary key of the table, and so it tries to execute an UPDATE statement.

The easiest solution now is to drag a "custom code" action before the "db save" and use this code:

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


Next update will have a db save option to force an INSERT all time.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.