when i using 

$command = Yii::app()->db->createCommand("
                        SELECT * 
                        FROM vote v
                        LEFT JOIN works w
                            ON w.id = v.works_id
                        LEFT JOIN activity a
                            ON a.id = w.activity_id
                        WHERE a.id = $activityId 
                            AND v.vote_date = '$date'
                            AND v.username = '$username'
                    ");
                    $rows = $command->query();

run it, and got these error: 

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.

after google, i got that is because in MySQL, it can NOT using multi query.

So, in Yii, resolving this problem is easy, just using this code before using createCommand:

Yii::app()->db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); 

 

Have fun with Yii!

 

 

 

 

 

相关文章:

  • 2021-08-27
  • 2021-09-16
  • 2022-01-31
  • 2021-07-25
  • 2021-05-18
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2021-09-06
  • 2021-12-30
  • 2021-11-14
相关资源
相似解决方案