Question

I'm getting a list of 'team' entities where each 'team' entity has two foreign keys to a 'user' entity. When a 'team' entity is created from a query, the entity will also end up containing all data for the two user accounts. I don't want this to happen because it contains sensitive data like the password. This is OK to have in certain features of this application, but currently I am creating a RESTful API (FOSRestBundle) and returning a team entity through the api gives someone access to sensitive data.

Currently, this is how I get all team entities:

public function findAllTeams()
{
    return $this->getEntityManager()
        ->createQuery("SELECT t FROM MyBundle:TableTeam t")
        ->getResult();
}

The team table has two foriegn keys: pidOne and pidTwo that map to the user account table.

Is there a way I can modify this function such that it does not automatically link the user account data with team entity?

THANKS

Was it helpful?

Solution

Use

->setHint(\Doctrine\ORM\Query::HINT_INCLUDE_META_COLUMNS, true)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top