0

I have, for example, a "products" entity and an "orders" entity and a "customers" entity. using doctrine, if I execute

return $this->getEntityManager()
        ->createQuery(
            'SELECT p FROM MyApplicationBundle:Products p ORDER BY p.name ASC'
        )
        ->getResult();

I get a collection of products with orders and customers related information. this collection is too big and I'm worried it can take too much memory. is there a way to take only the products information? I'd need it only for this query so I don't want to modify the relation in the product entity class.

thanks

1
  • You can specify the fields you to retrieve, for example. Commented Feb 18, 2015 at 10:56

1 Answer 1

2

You can mark the association as Extra Lazy in your Entity, this should prevent it from being automatically included in your query.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer but I need all the informations in other part of the application, so I prefernot to change it in the doctrine definition

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.