0

When usually fetching an entity from database with doctrine, you get all the related entities as actual classes, which causes a huge JOIN query, if you have lots of relations.

But sometimes I just want to get the actual object, not all the associated entities, just their IDs.

Is it possible to tell doctrine to just fetch the main entity and leave alone the relations?

Update: Sorry, missed the version: I'm using Doctrine 1.2 on a old project.

Johannes Klauß
  • 10,676
  • 16
  • 68
  • 122

1 Answers1

1

By default Doctrine use "lazy-loading": it will not retrieve the associated entities if you do not try to access them.

If you just use the ID of the main entity, it will never retrieves the associated entities.

If you want it to be even more lazy, try using the EXTRA_LAZY param.

adrien
  • 4,399
  • 26
  • 26