Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony原则-选择具有特定角色的用户_Php_Symfony_Doctrine_Doctrine Query_Symfony5 - Fatal编程技术网

Php Symfony原则-选择具有特定角色的用户

Php Symfony原则-选择具有特定角色的用户,php,symfony,doctrine,doctrine-query,symfony5,Php,Symfony,Doctrine,Doctrine Query,Symfony5,我试图从SQLite数据库(条令)中选择用户,但我只想选择角色为_ADMIN的教师,但它不起作用,我得到了错误 以下是查询代码: $teachers = $em->createQueryBuilder() ->select('t.username, t.firstName as firstname, t.surname, t.email, t.id') ->from('App:User\User', 't') ->where('t.roles

我试图从SQLite数据库(条令)中选择用户,但我只想选择角色为_ADMIN的教师,但它不起作用,我得到了错误

以下是查询代码:

$teachers = $em->createQueryBuilder()
     ->select('t.username, t.firstName as firstname, t.surname, t.email, t.id')
     ->from('App:User\User', 't')
     ->where('t.roles LIKE :role')
     ->setParameter('role', '%"ROLE_ADMIN"%')
     ->getQuery()
     ->getResult();
我得到了这个错误:

[语义错误]第0行第99列“类似角色:”:错误:无效 路径表达式。必须是StateFieldPathExpression

你能帮忙吗?

删除双引号

->setParameter('role', '%ROLE_ADMIN%')

不起作用,仍然是相同的错误:[语义错误]第0行,第99列“类似角色:”:错误:无效的PathExpression。必须是StateFieldPathExpression。我测试了建议的修复程序,它运行正常。缓存问题?为什么从('App:User\User','t')中有此
->?尝试从(User::class,'t')
发布您的
角色映射吗?