public function getUserQuery($userId) { $qb = $this->createQueryBuilder(); $qb->select('*'); if (is_numeric($userId)) { $qb->where('id = :userId'); } else { $qb->where($qb->expr()->like('username', ':userId'))->orWhere('email = :userId'); } $qb->setParameter('userId', $userId); return $qb; }