Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony: Why the isInitialized always is false?

I used doctrine query a user:

$customer = $this->getDoctrine()->getRepository('DemoUserBundle:Customer')->find(1);

But i got the result:

Customer {#1441 ▼ +isInitialized: false -id: 1 -username: null -nickname: null -email: null -salt: null -password: null -roles: null -enabled: null -lastLogin: null -expired: null -expiredAt: null -created: null -modified: null -group: null -ceilphoneCode: null -avatar: null -tasks: null -applications: null -companies: null -creators: null -images: null -company: null -store: Store {#1440 ▶} -realName: null -sex: null -age: null -belongCompany: null -address: null -career: null -relationProducts: null -attributes: null -medias: null -logs: null …2 }

the result is not completed, where are other data of this user? why the isInitialized is false?

like image 450
Mike Zhang Avatar asked Dec 20 '16 05:12

Mike Zhang


1 Answers

I added fetch="EAGER" to an other entity which called this entity and it is Ok for me.

Try $customer = $this->getDoctrine()->getRepository('DemoUserBundle:Customer')->find(1);

and $customer = $this->getDoctrine()->getRepository('DemoUserBundle:Customer')->find(2);

And you will understand.

like image 104
ouriels Avatar answered Sep 21 '22 04:09

ouriels