Note that there are some explanatory texts on larger screens.

plurals
  1. POYii - create temporary table and using it in next query produces General error: 2014 Cannot execute queries while other unbuffered queries are active
    primarykey
    data
    text
    <p>I am creating temporary table to hold some dates in first query. And in second query I try to join with those dates... and than i get following error: </p> <p>SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute..</p> <p>First query:</p> <pre><code> $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()-&gt;db-&gt;createCommand($query)-&gt;execute(); </code></pre> <p>Second query</p> <pre><code>$command = Yii::app()-&gt;db-&gt;createCommand() -&gt;select('allDays.days as periodDay, numberOfSentRequests, numberOfReceivedRequests, numOfLogins, numOfProfilesViewed') -&gt;from("(" . $commandDates-&gt;getText() . ") allDays") -&gt;leftJoin("(" . $commandProfileViewed-&gt;getText() . ") accessLog", 'allDays.days = accessLog.days').... </code></pre> <p>When I try to run second query:</p> <pre><code>return new CSqlDataProvider($command-&gt;getText(), array( 'totalItemCount' =&gt; count($allDatesInsideInterval), 'pagination' =&gt; array( 'pageSize' =&gt; self::PAGE_SIZE ), ... </code></pre> <p>I have seen that I need to do fetchAll(); and closeCursor(); ... but how to do it in Yii? Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload