我的控制器是:
/**
* @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;
}
枝条:
<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.
“提交”与Doctrine ORM查询无关,为什么会出现错误?