
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 | hits: 157 | expires: Never
$query = "DROP TABLE if exists TempDatesTable;";
$query .= "CREATE TEMPORARY TABLE TempDatesTable ( days char(20) ) TYPE=HEAP DEFAULT CHARSET=utf8;";
foreach ($allDatesInsideInterval as $date) {
$query .= "INSERT INTO TempDatesTable VALUES( '$date' );";
}
Yii::app()->db->createCommand($query)->execute();
$command = Yii::app()->db->createCommand()
->select('allDays.days as periodDay, numberOfSentRequests, numberOfReceivedRequests, numOfLogins, numOfProfilesViewed')
->from("(" . $commandDates->getText() . ") allDays")
->leftJoin("(" . $commandProfileViewed->getText() . ") accessLog", 'allDays.days = accessLog.days')....
return new CSqlDataProvider($command->getText(), array(
'totalItemCount' => count($allDatesInsideInterval),
'pagination' => array(
'pageSize' => self::PAGE_SIZE
),
...
$command = false;
$query = "DROP TABLE if exists TempDatesTable;";
$query .= "CREATE TEMPORARY TABLE TempDatesTable ( days char(20) ) TYPE=HEAP DEFAULT CHARSET=utf8";
foreach ($allDatesInsideInterval as $date) {
$query .= "; INSERT INTO TempDatesTable VALUES( '$date' )";
}