Error inserting multiple children in subform
Posted: Thu Dec 30, 2021 12:41 pm
Hello from Portugal!
I am facing a problem submitting multiple items via a subform. I did search the forum but nothing came up regarding this particular issue (could also be lack of caffeine)...
If I add one item (child) and save the main form, the item is properly saved. If I add 2 (or more) items like shown below and save, only the 1st one goes through and I get a MySQL error for the rest (error is shown below for better readability). The picture below shows the form and subform I am using. Please disregard the fact I am always using the same value for column 1, this is allowed. I was able to trace the problem to the automatic generation of the INSERTS by nuBuilder, because for the 1st item the query is
However, for the second child item, the INSERT becomes
As you can see in this case, a full statement was generated, when in fact only columns 1 and 2 were needed. With this INSERT i bump into the issue that the 3rd and 4th columns expect integers (or NULLs) but not empty strings.
Anyway, would anyone know if this behaviour is expected from nuBuilder (different INSERT statements for the 1st and subsequent children) or have I completely misconfigured my subform?
The logged error was
Thank you in advance for your help!
I am facing a problem submitting multiple items via a subform. I did search the forum but nothing came up regarding this particular issue (could also be lack of caffeine)...
If I add one item (child) and save the main form, the item is properly saved. If I add 2 (or more) items like shown below and save, only the 1st one goes through and I get a MySQL error for the rest (error is shown below for better readability). The picture below shows the form and subform I am using. Please disregard the fact I am always using the same value for column 1, this is allowed. I was able to trace the problem to the automatic generation of the INSERTS by nuBuilder, because for the 1st item the query is
Code: Select all
INSERT INTO provas_historico (`prvh_prova_id`, `prvh_arbitro_id`) VALUES ('1', '3')
Code: Select all
INSERT INTO provas_historico (`prvh_prova_id`, `prvh_arbitro_id`, `prvh_funcao_id`, `prvh_funcaosecundaria_id`, `prvh_disponibilidade`, `prvh_confirmado`, `prvh_nomeado`) VALUES ('1', '3', '', '', '0', '0', '0')
Anyway, would anyone know if this behaviour is expected from nuBuilder (different INSERT statements for the 1st and subsequent children) or have I completely misconfigured my subform?
The logged error was
Code: Select all
[0] :
===USER==========
globeadmin
===PDO MESSAGE===
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'prvh_funcao_id' at row 1
===SQL===========
INSERT INTO provas_historico (`prvh_prova_id`, `prvh_arbitro_id`, `prvh_funcao_id`, `prvh_funcaosecundaria_id`, `prvh_disponibilidade`, `prvh_confirmado`, `prvh_nomeado`) VALUES ('1', '3', '', '', '0', '0', '0');
===BACK TRACE====
/var/www/html/cacftp-nu/core/nudata.php - line 422 (nuRunQuery)
/var/www/html/cacftp-nu/core/nuapi.php - line 85 (nuUpdateDatabase)