简体   繁体   中英

Symfony2 Entity method called in repository class

How can I call method from entity class in repository class. I had tried to do something like this, but no success.

class ProfileConnectionsListRepository extends EntityRepository
{
       public function connectionUserNames($userId)
       {
           $connections = $this->_em
               ->findOneBy(array('user1Id' => $userId))
               ->getUser2Id();
       }
}

so if this is invalid can do something like that on doctrine way without using raw queries.

You might need to get repository first.

$connections = $this->_em
   ->getRepository(UserEntity::class)
   ->findOneBy(array('user1Id' => $userId))
   ->getUser2Id();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM