Forums

Two DB Save to different tables

yusufo 11 Sep, 2016
Hi,

I have two DB Save actions to save data on two different tables of the Joomla DB.

- The first one saves the data over _users table (it works great).
- The second db save saves the date over a custom tablet created by Chronoforms "Create Table" button (it does not work because it makes two insert on _users table) although this db action is configured to save in "lbqfh_chronoengine_chronoforms_datatable_Unete".

Also, I have unset the id hidden field before second db save and checked that all the columns present in "lbqfh_chronoengine_chronoforms_datatable_Unete" are fields on the form.

Please, can you help me? Thanks.
GreyHead 15 Sep, 2016
Hi yusufo,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here. That should show the database queries that are being created.

Bob
yusufo 20 Sep, 2016
Hi Bob,

The same happens with another form. This is the code of the debugger:

Array
(
    [chronoform] => DatosEntidades
    [event] => submit
    [id] => 38
    [ONG] => Fundación Spínola Solidaria
    [Data] => Array
        (
            [1] => Array
                (
                    [delegacion] => Madrid
                    [domicilio] => Prueba
                    [codigoPostal] => 28016
                    [ciudad] => Madrid
                    [provincia] => Madrid
                    [personaContacto] => Joaquin
                    [emailContacto] => joaquin@gmail.com
                    [idDelegacion] => 
                    [idONG] => 38
                )

            [id] => 39
        )

    [aceptoPoliticaPrivacidad] => Aceptada
    [bEnviar] => Enviar
    [ip_address] => 80.58.140.73
)

Array
(
)

Errors

Array
(
)

Debug Info

Array
(
    [2] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `lbqfh_chronoengine_chronoforms_datatable_DatosEntidades` (`id`, `ONG`, `aceptoPoliticaPrivacidad`, `user_id`, `uniq_id`, `created`) values ('', 'Fundación Spínola Solidaria', 'Aceptada', '446', '48ef5c84d57b3b70fbafe1634f8c2b4deba00308', '2016-09-20 08:35:16');
                        )

                )

        )

    [3] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `lbqfh_chronoengine_chronoforms_datatable_DatosEntidades` (`uniq_id`, `created`) values ('44aec8c93f1bb29631987046c750841329fe75bd', '2016-09-20 08:35:16');
                        )

                )

        )


The second query shoul be INSERT INTO `lbqfh_chronoengine_chronoforms_datatable_Entidades_Delegaciones` ('delegacion','domicilio','codigoPostal','ciudad','provincia','personaContacto','emailContacto','idONG') VALUES (...)

The primary key of this table is "idDelegacion".

Thanks.
GreyHead 20 Sep, 2016
Hi yusufo,

I can't work out why a DB Save would try to save to the wrong table. Please double-check the table setting in the action.

Bob
yusufo 20 Sep, 2016
I don't understant too.
I have attached two images of the db saves configuration:

[attachment=0]firstDBSave.png[/attachment]
[attachment=1]secondDBSave.png[/attachment]

On a custom action, I have this code but it doesn't work:

    <?php
    foreach  ($form->data['Data'] as $k => $v ) {
      $form->data['Data'][$k]['idONG'] = $form->data['id'];
    }
    unset($form->data['id']);
    ?>


Thanks Bob!!
vividal 16 Apr, 2017
was there ever a solution to this issue b/c I am experiencing the same issue?
acmac 06 Nov, 2017
I just faced this issue in CFv5. Joomla! 3.8.1 Stable with PHP version 5.6.31.

The below steps solved the matter.
from:
http://www.chronoengine.com/forums/posts/t101427/db-save-create-to-3-tables-third-one-updates-wrong-table?startat=0

Save the form after setting Save Under Model ID to yes, then unset that again. Then, it works as expected.

Thanks.
This topic is locked and no more replies can be posted.