Hi.
I'm trying to make a simple form but I still have problem to save.
I want this form to save and insert.
This are all information I have.
I'm trying to make a simple form but I still have problem to save.
I want this form to save and insert.
This are all information I have.
===TABLE===========================================
CREATE TABLE `cat5_org` (
`org_id` int(11) NOT NULL,
`org_sigla` varchar(50) NOT NULL,
`org_nome` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
ALTER TABLE `cat5_org` ADD PRIMARY KEY (`org_id`);
ALTER TABLE `cat5_org` MODIFY `org_id` int(11) NOT NULL AUTO_INCREMENT;
========================================
===Form, from beginning=================
========================================
New form => empty form
Settings
Title: orgaos
Alias: orgaos
Debug: on
Multi page Form: off (otherwise it keeps showing the same data over and over)
pages/Views
new text field/General
Label: Sigla
Name: org_sigla
Value: {var:read_data3.Data3.org_sigla}
new text field/General
Label: Nome
Name: org_nome
Value: {var:read_data3.Data3.org_nome}
new Button/General
type: submit
new Hidden field/General
name: org_id
Value: {var:read_data3.Data3.org_id}
pages/Actions/load
new Read Data (read_data3; model name: Data3)
Database table: cat5_org
Select type: First maching record
Where conditions
org_id = {data:id}
pages/Actions/submit
new Save Data
Database table: cat5_org
Data provider: {Data3}
=============================================================================================
Case 1 - Update =============================================================================
http://www.conhecimentopublico.com.br/index.php?option=com_chronoforms6&chronoform=orgaos&id=112
====Debug Load===============================================================================
Array
(
[option] => com_chronoforms6
[chronoform] => orgaos
[id] => 112
[rot] => http://www.conhecimentopublico.com.br/C5/tabelas/orgaos?ope=rev
[pes] => 648
[Itemid] =>
[event] => submit
[org_sigla] => MAPAaaab22
[org_nome] => Ministério da Agricultura, Pecuária e Abastecimento
[button3] =>
[org_id] => 112
)
Array
(
[read_data3] => Array
(
[log] => Array
(
[0] => SELECT `Data3`.`org_id` AS `Data3.org_id`, `Data3`.`org_sigla` AS `Data3.org_sigla`, `Data3`.`org_sigla_longa` AS `Data3.org_sigla_longa`, `Data3`.`org_nome` AS `Data3.org_nome`, `Data3`.`org_nome_ident` AS `Data3.org_nome_ident`, `Data3`.`org_pai_id` AS `Data3.org_pai_id`, `Data3`.`org_sup_id` AS `Data3.org_sup_id`, `Data3`.`org_nivel` AS `Data3.org_nivel`, `Data3`.`org_seq` AS `Data3.org_seq`, `Data3`.`org_seq_fim` AS `Data3.org_seq_fim` FROM `cat5_org` AS `Data3` WHERE `Data3`.`org_id` = '112' LIMIT 100;
)
[var] => Array
(
[Data3] => Array
(
[org_id] => 112
[org_sigla] => MAPAaaab
[org_sigla_longa] => MAPAzaz
[org_nome] => Ministério da Agricultura, Pecuária e Abastecimento
[org_nome_ident] => Ministério da Agricultura, Pecuária e Abastecimento
[org_pai_id] => 0
[org_sup_id] => 112
[org_nivel] => 1
[org_seq] => 8000
[org_seq_fim] => 15999
)
)
)
)
===================================================================================================
=== RESULT===================================
error
1062 Duplicate entry '112' for key 'PRIMARY'
===================================================================================================
Case 2 - Update =======================================================================
http://www.conhecimentopublico.com.br/index.php?option=com_chronoforms6&chronoform=orgaos&id=112
===Debug load=====================================================================
Array
(
[option] => com_chronoforms6
[chronoform] => orgaos
[id] => 0
[rot] => http://www.conhecimentopublico.com.br/C5/tabelas/orgaos?ope=rev
[pes] => 648
[Itemid] =>
)
Array
(
[read_data3] => Array
(
[log] => Array
(
[0] => SELECT `Data3`.`org_id` AS `Data3.org_id`, `Data3`.`org_sigla` AS `Data3.org_sigla`, `Data3`.`org_sigla_longa` AS `Data3.org_sigla_longa`, `Data3`.`org_nome` AS `Data3.org_nome`, `Data3`.`org_nome_ident` AS `Data3.org_nome_ident`, `Data3`.`org_pai_id` AS `Data3.org_pai_id`, `Data3`.`org_sup_id` AS `Data3.org_sup_id`, `Data3`.`org_nivel` AS `Data3.org_nivel`, `Data3`.`org_seq` AS `Data3.org_seq`, `Data3`.`org_seq_fim` AS `Data3.org_seq_fim` FROM `cat5_org` AS `Data3` WHERE `Data3`.`org_id` = '0' LIMIT 100;
)
[var] =>
)
)
===Debug submit=====================================================================
Array
(
[option] => com_chronoforms6
[chronoform] => orgaos
[id] => 0
[rot] => http://www.conhecimentopublico.com.br/C5/tabelas/orgaos?ope=rev
[pes] => 648
[event] => submit
[org_sigla] => aaa teste
[org_nome] => aaa teste
[button3] =>
[org_id] =>
[Itemid] =>
)
Array
(
[submit_validate_fields] => Array
(
[log] => Automatic validation enabled.
[var] => 1
)
[save_data4] => Array
(
[data] => Array
(
[created] => 2020-03-13 16:37:18
[user_id] => 648
[org_sigla] => aaa teste
[org_nome] => aaa teste
[org_id] =>
)
[_success] => Data saved successfully
[log] => Array
(
[0] => INSERT INTO `cat5_org` (`org_sigla`, `org_nome`, `org_id`) values ('aaa teste', 'aaa teste', '');
)
[var] => Array
(
[org_sigla] => aaa teste
[org_nome] => aaa teste
[org_id] => 241
)
)
)
You can't INSERT the same primary key into the database, you either need to enter a new row (without the primary key) or UPDATE an existing row
I know I can't "INSERT the same primary key into the database".
The point is, why "write action: Auto detect" didn't work?
The point is, why "write action: Auto detect" didn't work?
Dunno, I never use it I always manually override. Try insert on duplicate update
"Manually overrides"? How? With a custom code block and writing SQL commands?
Someone told me to READ BLOCK on submit section and use the FOUND and NOTFOUND sections. Didn't look very efficient.
Someone told me to READ BLOCK on submit section and use the FOUND and NOTFOUND sections. Didn't look very efficient.
Manual overrides as in leave data source empty, and use the data overrides to specify what data goes in which columns.
What happens when the Save Data mode is set to "Insert on duplicate update" ?
Insert and Update works ok. I will use it.
I would still like to know why such a simple form doesn't work.
But I have to go ahead, so I will use this insert option.
Thanks
I would still like to know why such a simple form doesn't work.
But I have to go ahead, so I will use this insert option.
Thanks
Please explain what exactly does NOT work now ?
This topic is locked and no more replies can be posted.