我正在尝试更新Shopware中的客户属性,但出现错误

时间:2018-08-17 05:57:10

标签: php mysql shopware customer

我正在尝试在Shopware中更新客户属性,但出现错误

$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();
  

致命错误:未捕获的学说\ ORM \ Query \ QueryException:无效   参数:查询中未定义令牌电子邮件。在   /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134   堆栈跟踪:#0   /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(362):   主义\ ORM \ Query \ QueryException :: unknownParameter('email')#1   /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(319):   原则\ ORM \ Query-> processParameterMappings(Array)#2   /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962):   主义\ ORM \ Query-> _ doExecute()#3   /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(917):   主义\ ORM \ AbstractQuery-> executeIgnoreQueryCache(NULL,NULL)#4   /var/www/html/shopware/custom/plugins/CustomPlugin/Controllers/Frontend/CustomPlugin.php(17):   教义\ ORM \ AbstractQuery-> execute()#5   /var/www/html/shopware/engine/Library/Enlight/Controller/Action.php(193):   Shopware_Controllers_Frontend_CustomPlugin-> indexAction()#在   /var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php   在第134行

1 个答案:

答案 0 :(得分:1)

  • 尝试使用这样的where语句;

    ->where('customer.email = ?1')->setParameter(1 ,'xyz@test.com');