何时是将$ _SESSION数组中的大量值写入数据库中的记录的最佳时间?

One of my MySQL database's tables has 125 columns. I am gathering the values for these columns by presenting the user with a large number of forms in which they select or enter values that I store in the $_SESSION array.

Given there are 125 values to be stored in the $_SESSION array, when would be the best time to start writing these values into the MySQL database?

I may be answering my own question, but would love to hear from more experienced people. I am guessing the safest method is to write one column value at a time into MySQL. And, I am guessing again, is the quickest way assembling all 125 column values and then writing them all in one INSERT statement into MySQL?

It depends on your need. Do you only need to record the data once all 125 fields are collected, or do you you want to collect partial (incomplete) data a field at a time? Your need here should determine your strategy around how to persist this data to the database.

Presumably you are stuck with this data design. It sounds very unwieldy.

At any rate, if you actually have all the data items available you should put them into MySQL with a single INSERT.

If you do an INSERT and then a bunch of UPDATE operations, you'll have to figure out how to get your UPDATEs to hit the row you just INSERTed. That can sometimes be a little tricky.