Forums

How to save data in multiple tables

kmikko 21 May, 2015
Made too large form and while saving information to database had following MySQL problem

"Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help."

For me its not possible to make some columns to text or blob so I decided to split table in three parts.

My quess is that this needs 3 times "DB Save". The problem is that "DB save" saves everything. The question is how can I select which values are saved in each table. Primary key should be id for each table so information stays in order when updating in future.
kmikko 21 May, 2015
Thank you for these. However, these did not help.

-kmikko
kmikko 22 May, 2015
Some update.

Made test with 2 tables and first table gets all information that needed but second table doesn't save anything. Both tables have
chronoforms columns id, uniq_id, user_id, created and modified.

Tested this http://www.chronoengine.com/forums/posts/f2/t97328.html?page=2
Didn't work. Result was 2 same rows in table1. Just little confused.
kmikko 22 May, 2015
Another update.

Hadto create tables again so they where in sync with id.

Now the problem is that CF saves columns id, uniq_id, user_id, created and modified. All the actual data is left somewhere.

Here is debug

Data array

Array
(
    [option] => com_chronoforms5
    [chronoform] => Datav1add
    [event] => submit
    [name] => test
    [acronym] => test
    [host] => test
    [address] => test
    [zipcode] => test
    [country] => Belgium
    [www] => test
    [site] => test
    [owner] => test
    [year] => test
    [button37] => Submit
    [Data] => Array
        (
            [id] => 2
        )

    [2nd_table_pkey] => 
    [Information] => Array
        (
            [id] => 2
        )

    [ip_address] => xx.xxx.x.xxx

)


Errors

Array
(
)


Debug info

Array
(
    [8] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `Datameasurements` (`user_id`, `uniq_id`, `created`) values ('0', '2yae5dd221901a0b15cb9c4be5cc930693e5537f', '2015-05-22 10:50:34');
                        )

                )

        )

    [5] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `Datainformation` (`user_id`, `uniq_id`, `created`) values ('0', '46714989efc34a0323933e640d848177f237fb94', '2015-05-22 10:50:34');
                        )

                )

        )


GreyHead 22 May, 2015
Hi kmikko,

Unless you have an enormous number of columns I would suggest that you adjust the column sizes to reduce the number of VARCHAR(255) columns - often VARCHAR(8) or (64) is enough. Please see this FAQ

Bob
kmikko 22 May, 2015
Hi Bob ant thank you for your answer.

I allready tried to make smaller columns and had this same error
"Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help." So I quess this is restrict with server and I don't have rights to make table larger.

Do you have any suggestions for what goes wrong whit this 2 table save.
I can see that DB save arrays doesn't get all the information they need. How can I update that info.

What I have now
There is 2 DB saves with different Model ID and
before second DB save there is custom code
 <?php
    $form->data["2nd_table_pkey"] = $form->data["id"]; 
    unset($form->data["id"]); 
?>
kmikko 22 May, 2015
Wery strange just had thisone working. Just changed use model id to No and zap it worked. Could this be so easy solution or am I missing something?
This topic is locked and no more replies can be posted.