There are three objects: Client, Messages, Attachments.
The relationship between these objects is straightforward: the client can have many messages, and the message can have many attachments. Both are one-to-many relationships.
I told the doctrine lazy when loading messages for the Customer object. Thus, $customer->getMessages() leads to an additional SQL query. It's fine.
But I also defined the "EAGER" load for attachments for the Message object.
Now I expected that the messages received when calling $customer->getMessages() were already loaded with all their attachments. But $message->getAttachments() still calls one SQL statement for each message.
Is this behavior expected?
For reference only, except for my classes:
Customer.php
class Customer { private $messages;
message.php
class Message { private $id; private $customer; private $attachments;
attachment.php:
class Attachment { private $id; private $message;
symfony doctrine2
Jens
source share