Store Data Temporarily Before Saving Into Database

I am developing an application using Yii framework where I need to store data temporarily before saving into database.The screen is divided into master and detail. The detail part is shown using CGridview. I want to store the data in CGridview tempoarily and when the save button is clicked it will be stored into database. The temporary data should be editable and can be deleted. I thought of storing it in session, but then how can I generate new primary key ID for the rows? Also emptying the table and then inserting all the values in CGridview into table is not possible, because I am linking those IDs to a history table of the same data.How can I do this? Please help.

Hi candyman

One of following solutions may help to solve your problem.

  1. Maintaining a temporary table to store temporary data.

    You will be able to create a separate table to maintain the temporary data, Once the editing done, simply move the data into live table.

  2. Use a combination of session && transaction

    (Set the session manually , Set the model object into the session, reuse the session + object , Commit once the process done,)

  3. Maintaining a status in the database.

    Maintain 2 status in the database - (1 => Live 2 => On Processing)


Sri Nuwan Perera

I am having the same problem. But I have no working solution yet.

One thing that I was thinking of is using CGridView + CArrayDataProvider for the details. Once, save button is pressed, then the CArrayDataProvider will be stored in database. But I am not yet trying it :)