This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Yii - create temporary table and using it in next query produces General error: 2014 Cannot execute queries while other unbuffered queries are active

By: a guest on Apr 7th, 2012  |  syntax: None  |  size: 1.20 KB  |  views: 425  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $query = "DROP TABLE if exists TempDatesTable;";
  2.     $query .= "CREATE TEMPORARY TABLE TempDatesTable ( days char(20) ) TYPE=HEAP  DEFAULT CHARSET=utf8;";
  3.  
  4.     foreach ($allDatesInsideInterval as $date) {
  5.         $query .= "INSERT INTO TempDatesTable VALUES( '$date' );";
  6.     }
  7.  
  8.     Yii::app()->db->createCommand($query)->execute();
  9.        
  10. $command = Yii::app()->db->createCommand()
  11.                     ->select('allDays.days as periodDay, numberOfSentRequests, numberOfReceivedRequests, numOfLogins, numOfProfilesViewed')
  12.                     ->from("(" . $commandDates->getText() . ") allDays")
  13.                     ->leftJoin("(" . $commandProfileViewed->getText() . ") accessLog", 'allDays.days = accessLog.days')....
  14.        
  15. return new CSqlDataProvider($command->getText(), array(
  16.         'totalItemCount' => count($allDatesInsideInterval),
  17.         'pagination' => array(
  18.             'pageSize' => self::PAGE_SIZE
  19.         ),
  20.         ...
  21.        
  22. $command = false;
  23.        
  24. $query = "DROP TABLE if exists TempDatesTable;";
  25. $query .= "CREATE TEMPORARY TABLE TempDatesTable ( days char(20) ) TYPE=HEAP  DEFAULT CHARSET=utf8";
  26.  
  27. foreach ($allDatesInsideInterval as $date) {
  28.     $query .= "; INSERT INTO TempDatesTable VALUES( '$date' )";
  29. }
clone this paste RAW Paste Data