Buy Now
Sign in

Read and write data from MySQL

Twickbot , June 02 2017, 09:24
T
Twickbot 33
June 02 2017, 09:24 #368921
I create form with two text fields and one button "Save".

I want to do:
1. When form is opened fill this two text fields with text from two сorresponding fields of MySQL's table.
2. When I change text in this form's fields and press button "Save" new text must be written in MySQL.

Is it possible with CC6?

Thank you in advance for any help.
S
surendersingh 8
June 02 2017, 10:31 #368922
Yes it is possible by action Read Data and Save Data Action in Setup tab.
T
Twickbot 33
June 02 2017, 10:54 #368924
Thank you for answer.
I try to read "Chronoforms start guide" and "FAQs" but didn't find info about how to realease my task.
Can u explane me what should I do step by step?
Or where can I read about it?
T
Twickbot 33
June 02 2017, 15:39 #368950
Ok.
1. In Designer I created page with two text fields.
2. In Setup I created Read Data for read data from MySQL.
In Debug section I see that data was read correct from DB.

What should I write in Text Field's value to show data retrieved from MySQL?

Didn't find any info.
admin 28
June 04 2017, 06:10 #368981
 Answer
Hi Twickbot,

The read data should be above the "display section", and most probably you want to read one record only and so the read data should be configured to read the first matching record.

Now you can use this in the "Value" setting of your field:

{var:read_data_name.Model.table_field}


Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
T
Twickbot 33
June 10 2017, 19:30 #369230
Many thanks!
It worked!

One more question:
I change the value in this field.

What should I prescribe in the settings of the "Save" button so that the new value will save in the database?
admin 28
June 11 2017, 22:46 #369252
Hi Twickbot,

How do you have the "Save data" action configured ?

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
T
Twickbot 33
June 11 2017, 22:55 #369255
Not yet configured.
What I must to write in "Value" field?
admin 28
June 11 2017, 23:29 #369256
The Save data action will save the form data assuming that a table is selected and the "data provider" is set to {data:} and that the table fields names match the form fields names.

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
T
Twickbot 33
June 12 2017, 22:28 #369322
In "Setup" => "submit" tab I added "Save Data" then:

- "Model name" - write name.
- "Database table" - select table.
- "Data provider" - {data:}.
- "Write action" - Update
- "Update conditions" - cms_id:{user:id}

But when I change data and press "Save" button on page data is not written to the database.

What am I doing wrong?
T
Twickbot 33
June 13 2017, 22:42 #369359
Ок.
By trial and error, I learned how to write data to the database.
Thanks for the help.