SHARE
TWEET

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

a guest Apr 7th, 2012 532 Never
  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. }
RAW Paste Data
Top