Active Record Using Temporary Table

Hi

I create a mysql temporary table for reporting purpose, I use active record and gridview for showing and searching in this temp table.

at first I couldn’t filter gridview results Although the table have been created and gridview showed data but after that the connection of activerecord automatically closed so the table whould be droped and searching in gridview throw an exception as

"The table "report" for active record class "Report" cannot be found in the database."

I solved this by configuring the db in config file as




'autoConnect' => false,

'persistent' => true,



but there’s another issue here, the created temporary table is different for different users but in this way if a user load the page the created table whould change for all users.

I really appreciate any help

Give a unique name to the temp table using a random string.

thank you Backslider, your right, it’s a simple solution for this issue, it could be the final solution but based on this explanation in mysql documention I prefer differect connection session for different users

"A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name."