php - 为什么我在 Shopware 中更新客户属性时收到无效参数错误?

标签 php mysql shopware

我尝试更新 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();

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

我该如何解决这个问题?

最佳答案

尝试使用这样的 where 语句;

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

关于php - 为什么我在 Shopware 中更新客户属性时收到无效参数错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51889192/

相关文章:

symfony - 从 Shopware 6 中的 HttpCacheHitEvent 获取 navigationId

php - PDO::FETCH_ASSOC PDO::FETCH_ARRAY 是什么?

php - 我如何在 PHP 中查看**所有**当前定义的变量?

php - 如何使用 php 从 seo 友好的 url 获取 id?

mysql - 通过ajax从mysql/php获取多维结果

mysql - 错误 1064 (42000) : errror near ' PRIMARY KEY

商店用品 6 : Extend existing core DAL entities with a reference

PHP 和 PostgreSQL,在数据库中注册新用户的最佳实践?

php - 如何在php中使用sql变量传递sql查询

twig - 如何获取 Shopware 6 中所有其他 channel 的当前产品或类别 url 等效项?