Yii Framework Forum: Active Record Using Temporary Table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Active Record Using Temporary Table Rate Topic: -----

#1 User is offline   Reza m 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 07-March 12

Posted 31 December 2012 - 01:26 PM

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
0

#2 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 363
  • Joined: 23-July 09

Posted 31 December 2012 - 01:33 PM

Give a unique name to the temp table using a random string.
We were all once expert at....... nothing.

yii-language-behavior

My Blog
1

#3 User is offline   Reza m 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 07-March 12

Posted 31 December 2012 - 04:00 PM

View PostBackslider, on 31 December 2012 - 01:33 PM, said:

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."
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users