duanqun9618
2018-08-17 05:57
浏览 68
已采纳

我试图更新Shopware中的客户属性,但收到错误

I am trying to update customer attribute in Shopware but getting error

$builder = $this->container->get('models')->createQueryBuilder()
                   ->update(\Shopware\Models\Customer\Customer::class, 'customer')
                   ->set('customer.active',0)
                   ->where('customer.email= :email')
                   ->setParameter('email ' ,'xyz@test.com');
        $builder->getQuery()->execute();

Fatal error: Uncaught Doctrine\ORM\Query\QueryException: Invalid parameter: token email is not defined in the query. in /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134 Stack trace: #0 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(362): Doctrine\ORM\Query\QueryException::unknownParameter('email ') #1 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(319): Doctrine\ORM\Query->processParameterMappings(Array) #2 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962): Doctrine\ORM\Query->_doExecute() #3 /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(917): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, NULL) #4 /var/www/html/shopware/custom/plugins/CustomPlugin/Controllers/Frontend/CustomPlugin.php(17): Doctrine\ORM\AbstractQuery->execute() #5 /var/www/html/shopware/engine/Library/Enlight/Controller/Action.php(193): Shopware_Controllers_Frontend_CustomPlugin->indexAction() # in /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php on line 134

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douhu2898 2018-08-17 06:07
    最佳回答
    • Try to use where statement like this;

      ->where('customer.email = ?1')->setParameter(1 ,'xyz@test.com');
      
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题