【发布时间】:2018-11-21 16:51:34
【问题描述】:
我正在尝试以这种方式 (Symfony4) 将数据插入到具有相应表的已创建数据库中:
/**
* @Route("/admin/user/new", name="admin_add_new_user")
*/
public function new_user(EntityManagerInterface $em)
{
$user = new User();
$user->setUsername('felipito')
->setPassword('canelo123')
->setEmail('fpcanelo@ati.cu');
$em->persist($user);
$em->flush();
return $this->render('admin/index.html.twig', [
'controller_name' => 'AdminController',
'brand' => 'brand',
'msg' => sprintf(
'New user dude: id #%d user %s', $user->getId(), $user->getUsername()
)
]);
}
一旦我打开网址,它会抛出以下内容:
An exception occurred while executing 'INSERT INTO user (username, roles, password, email) VALUES (?, ?, ?, ?)' with params ["felipito", "[]", "canelo123", "fpcanelo@ati.cu"]:
SQLSTATE [42000, 156]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near the keyword 'user'.
SQLSTATE [42000, 8180]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared.
可能问题与this problem I had yesterday有关
【问题讨论】:
标签: php sql sql-server symfony doctrine-orm