我有此代码:
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
。我不明白是什么原因导致了此错误。感谢您的帮助。