Php Symfony原则-选择具有特定角色的用户
我试图从SQLite数据库(条令)中选择用户,但我只想选择角色为_ADMIN的教师,但它不起作用,我得到了错误 以下是查询代码: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
$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')
发布您的角色映射吗?