Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用INSERT INTO进行SQL请求时出错_Javascript_Php_Sql_Symfony - Fatal编程技术网

Javascript 使用INSERT INTO进行SQL请求时出错

Javascript 使用INSERT INTO进行SQL请求时出错,javascript,php,sql,symfony,Javascript,Php,Sql,Symfony,当我试图将数据从控制器中放入数据库时,出现了一个错误,其中的表单包含一个文本。我检查了每个变量,没有一个是空的。因此,当我提交表格时,会出现以下错误: SyntaxErrorException: An exception occurred while executing 'INSERT INTO message (message, vu, from, date, type, id_player) VALUES (?, ?, ?, ?, ?, ?)' with params ["ds", 0, "

当我试图将数据从控制器中放入数据库时,出现了一个错误,其中的表单包含一个文本。我检查了每个变量,没有一个是空的。因此,当我提交表格时,会出现以下错误:

SyntaxErrorException: An exception occurred while executing 'INSERT INTO message (message, vu, from, date, type, id_player) VALUES (?, ?, ?, ?, ?, ?)' with params ["ds", 0, "jean3", "2017-05-05 18:04:39", "message", 7]:
我不明白为什么我的类型页可能是错误的,它应该是(String,boolean,String,datetime,String,int)。int是一个外键,所以我为最后一行(setIdPlayer和setPlayer)设置了我的控制器的ID和实体int

这是我的控制器:

公共功能操作(请求$Request)
{
$player=$this->container->get(“security.token_storage”)->getToken()->getUser();
$message=新消息;
//转储($player->getCharacters());
$form=$this->createFormBuilder($message)
->添加('message',TextareaType::class,array('label'=>'message:'))
->添加('registration',SubmitType::class,array('label'=>'Envoie du message'))
->getForm();
$form->handleRequest($request);
如果($form->isSubmitted()&&&$form->isValid())
{
如果($request->query->has('to'))
{
转储(“发送…”);
$message->setMessage($form['message']->getData());
$message->setFrom($player->getUsername());
$message->setVu(false);
$message->setDate(date_create());
$message->setType(“message”);
$to=$this->getDoctrine()->getRepository('AppBundle:Player'))
->findByPseudo($request->query->get('to'))[0];
$id_to=$to->getId();
转储($id_to);
倾倒(至美元);
$message->setIdPlayer($id\u to);
$message->setPlayer($to);
//TODO:获取depuis la数据库和lui foutre le消息
$em=$this->getDoctrine()->getManager();
$em->persist($message);//prépare l'insertion dans la BD
$em->flush();
}
}

}
我有一个语法错误,因为我有一个名为“date”的列,它在SQL中是一个保留字!所以我刚刚重新命名了我的专栏,它可以工作了


编辑:与“发件人”和“类型”相同

事实上,一切似乎都正常,试着直接在一些sql gui或mysql控制台中执行该查询,看看它在说什么。我不明白为什么要将
private
用作manytone关系属性,并将IdPlayer用作integere(具有相同的联接列)<代码>玩家已经足够了。您可以直接使用setPlayer。我在phpmyadmin中尝试此查询时也会出现相同的错误