SQLSTATE [HY000]:symfony中的常规错误创建表

时间:2018-07-27 08:05:42

标签: php symfony symfony-2.1

我有此代码:

try{
   $aws = $this->getContainer()->get(Service::class);
   $query = 'DROP TABLE IF EXISTS newtable;CREATE TABLE newtable LIKE actions;';
   $aws->executeQuery($query);
}catch (\Exception $exception){
  $output->writeln("Can't create new tables, with message :");
  $output->writeln(sprintf("%s", $exception->getMessage()));
}

还有服务类函数executeQuery

public function executeQuery($query, $multiple = true, $fetch = true)
{
    $res = $this->conn->prepare($query);
    $result = $res->execute();

    return ($fetch) ? ($multiple ? $res->fetchAll(\PDO::FETCH_ASSOC) : $res->fetch(\PDO::FETCH_ASSOC)) : $result;
}

表已创建,但出现错误消息: SQLSTATE[HY000]: General error。我不明白是什么原因导致了此错误。感谢您的帮助。

0 个答案:

没有答案