Symfony:为什么isInitialized总是错误的? [英] Symfony: Why the isInitialized always is false?
问题描述
我使用学说来查询用户:
I used doctrine query a user:
$customer = $this->getDoctrine()->getRepository('DemoUserBundle:Customer')->find(1);
但是我得到了结果:
客户{#1441▼
+ 已初始化:假
-id:1
-用户名:null
-昵称: null
-电子邮件:null
-盐:null
-密码:null
-角色:null
-已启用:null
-lastLogin:null
-过期:空
-expiredAt:空
-创建:空
-修改:空
-组:空
-ceilphoneCode:空
-头像:null
-任务:null
-应用程序:null
-公司:null
-创建者:null
-图片:null
-公司:null
-商店:Store {#1440▶}
-realName:null
-性别:null
-年龄:null
-belongCompany:null
-地址:空
-职业:空
-relationProducts:空
-属性:空
-媒体:空
-日志:空
…2
}
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 }
结果未完成,该用户的其他数据在哪里?为什么isInitialized为false?
the result is not completed, where are other data of this user? why the isInitialized is false?
推荐答案
我添加了 fetch = EAGER
I added fetch="EAGER"
to an other entity which called this entity and it is Ok for me.
尝试 $ customer = $ this-> getDoctrine()- > getRepository('DemoUserBundle:Customer')-> find(1);
和 $ customer = $ this-> getDoctrine()-> getRepository('DemoUserBundle:Customer')-> find(2);
您会明白的。
这篇关于Symfony:为什么isInitialized总是错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!