0
我想在遷移的up()方法中運行create SQL語句之前檢查是否存在表。在使用Symfony運行sql之前檢查表存在的問題sfPropelMigrationsLightPlugin
我可以運行類似:
$count = $this->executeSQL("SELECT count(*) FROM information_schema.TABLES where TABLE_NAME = 'table_name';");
if($count == 0)
{
$this->executeSQL("Create SQL ...");
}
的問題是,這將返回以下錯誤:
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.
任何想法如何解決這個問題?