Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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
Orm 奇怪错误:[语义错误]第0行,第75列靠近';提交';:错误:';提交';没有定义_Orm_Symfony_Doctrine Orm_Repository - Fatal编程技术网

Orm 奇怪错误:[语义错误]第0行,第75列靠近';提交';:错误:';提交';没有定义

Orm 奇怪错误:[语义错误]第0行,第75列靠近';提交';:错误:';提交';没有定义,orm,symfony,doctrine-orm,repository,Orm,Symfony,Doctrine Orm,Repository,我的控制器是: /** * @Route("/product/submit", name="product_submit") * @Template("GaorenVendorsBundle:Product:index.html.twig") */ public function submitAction() { $em = $this->getDoctrine()->getManager(); $uid = $this

我的控制器是:

  /**
   * @Route("/product/submit", name="product_submit") 
   * @Template("GaorenVendorsBundle:Product:index.html.twig")
   */
  public function submitAction()
  {
        $em = $this->getDoctrine()->getManager();
        $uid = $this->getUser()->getId();
        $em->getRepository( 'GaorenVendorsBundle:Product' )->updateStatus( $uid, Product::STATUS_FREE, Product::STATUS_PENDING );

        return $this->redirect( $this->generateUrl( 'product' ) );
  }
我的回购协议是:

class ProductRepository extends EntityRepository
{

  public function updateStatus($uid, $status, $setter)
  {
        $st = $this->getEntityManager()->getRepository( 'GaorenVendorsBundle:Product' )
              ->createQueryBuilder( 'p' )
              ->update( 'GaorenVendorsBundle:Product', 'p' )
              ->set( 'p.status', ':setter' )
              ->where( 'p.status= :status AND p.user= :user' )
              ->setParameters( array(
                      'user' => $uid,
                      'status' => $status,
                      'setter' => $setter
              ) )
              ->getQuery()
              ->execute()

        return $st;
  }
细枝:


“提交”与ORM查询无关,为什么它会出现在错误中?

可能是因为您有一条路径与该路径上方的路径匹配,如
/product/{id}

这将匹配您的
/product/submit
路线,并将
$id
视为字符串
“submit”
。第一条匹配路线在Symfony中获胜。然后,如果您尝试从此id检索产品对象,则可能会引发这样的错误


解决方案是将提交操作移到处理
/product/{id}
路由的操作之上。

我想这样做,但声誉不够,sry…:(
    <a class="btn btn-large btn-primary " href="{{ path('product_submit') }}">
        <i class="icon-plus icon-white"></i>
        {{ 'create a new entry'|trans }}
    </a>
[Semantical Error] line 0, col 75 near 'submit': Error: 'submit' is not defined.