我试图更新shopware中的customer属性,但出现错误

k4aesqcs  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(380)

我试图更新shopware中的customer属性,但出现错误

$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 stack 跟踪:#0/var/www/html/shopware/vendor/doctrine/orm/lib/doctrine/orm/query.php(362):条令\orm\query\queryexception::未知参数('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\u controllers\u frontend\u customplugin->indexaction()#in/var/www/html/shopware/vendor/doctrine/orm/lib/doctrine/orm/query/queryexception.php第134行

u4vypkhs

u4vypkhs1#

尽量使用where语句;

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

相关问题