我有以下ajax调用
var prev_sibling = $(this).prev().attr("value"); var next_sibling = $(this).next().attr("value"); var order = (prev_sibling + next_sibling)/2; var data = {PID:element_id,TGID:parent_id,ORD:order}; $.ajax({ type: "POST",data: data,url:"{{ path('v2_pm_patents_dragpatents') }}",cache: false });
在我的行动中,我得到了这样的命令,并设置它
$order = $request->get('ORD'); $patent->setOrder($order);
但是ajax电话给我以下错误
Syntax error or access violation: 1064 You have an error in your sql Syntax; check the manual that corresponds to your MysqL server version for the right Syntax to use near 'order = '750' WHERE id = '0d0c0810-bc75-11e1-96a5-9787dec335c2'' at line 1 (500 Internal Server Error)
我得到正确的帖子数据,给我这些记录的查询也正常工作.
哪里有问题?
有任何想法吗?
提前致谢
解决方法
问题是MysqL中的保留字.如果你使用原则,你可以告诉它在映射中转义保留字,如下所示:
/** @Column(name="`order`",type="integer") */ private $order;
http://docs.doctrine-project.org/en/latest/reference/basic-mapping.html#quoting-reserved-words