Hi,
on the site of my school i've a form that saves data into a db table (the table has a unique constraint on 3 field CodClasse+CodMateria+A_S).
I need this functionality: after the data are send, mysql should control the uniquue constraint and, eventually, return an error message. How can i do?
Regards, Paolo
on the site of my school i've a form that saves data into a db table (the table has a unique constraint on 3 field CodClasse+CodMateria+A_S).
I need this functionality: after the data are send, mysql should control the uniquue constraint and, eventually, return an error message. How can i do?
Regards, Paolo
Hi Paolo,
I'm not sure - probably you need to hand-code the MySQL query and handle any MySQL errors returned.
Bob
I'm not sure - probably you need to hand-code the MySQL query and handle any MySQL errors returned.
Bob
Hi Bob,
yes i suppose..can you help me?
Best regards, Paolo
yes i suppose..can you help me?
Best regards, Paolo
I will work on the "CodClasse" as an example.
I will suppose the DB field is named "CodClasse" and the value from the form is under "CodClasse_field"
Use a "DB Record loader" action and enter "CodClasse" in the "DB field" and enter "CodClasse_field" in the "Request Param" and select the db table, then save, in the "On Found" event add a "Custom code" action and enter this code:
Then add an "Event loop" action after the "Custom code" one.
Save the form, done!
You may need to have 3 "Record loader" actions for the 3 DB fields..
Regards,
Max
I will suppose the DB field is named "CodClasse" and the value from the form is under "CodClasse_field"
Use a "DB Record loader" action and enter "CodClasse" in the "DB field" and enter "CodClasse_field" in the "Request Param" and select the db table, then save, in the "On Found" event add a "Custom code" action and enter this code:
<?php
$form->validation_errors[] = "CodClasse is not unique because it has been found!";
?>
Then add an "Event loop" action after the "Custom code" one.
Save the form, done!
You may need to have 3 "Record loader" actions for the 3 DB fields..
Regards,
Max
This topic is locked and no more replies can be posted.
