user3818576
user3818576

Reputation: 3401

How to query in symfony that has an array?

The first thing that I do is to search all the users, and I successfully show all the users. Now I'm trying to query the roles of users, but it displays an array, like the image enter image description here

Do you have an idea on how to query this in symfony? or Is this allowed in symfony to query an array? I have no idea on how to do it. I try to search it to google but no result found. I'm just stuck on this query

$query =  $this->createQueryBuilder('u')
            ->where('u.role = :parameter')
            ->setParameter('parameter', 'ROLE_ADMIN')
            ->getQuery();

        return $query->getResult();

Upvotes: 1

Views: 171

Answers (1)

Chuck Norris
Chuck Norris

Reputation: 1123

Replace = by like :

->where('u.role like :parameter')
->setParameter('parameter', '%ROLE_ADMIN%')

Upvotes: 1

Related Questions