我有一个名为“强”的实体,名称为“强”类别(/强),包括以下领域:
id: integer
name: string
slug: string
children: OneToMany(targetEntity="Category", mappedBy="parent")
parent: ManyToOne(targetEntity="Category", inversedBy="children")
如你所见,每一类人可以是另一类人的子女的父母。
我需要将所有类别都映射成一个阵列 所以我想最好把它们一起装上
$categoryRepository->findAll();
稍后,在绘图方法上, 我想得到每个类别的孩子, 所以我使用
$category->getChildren();
我假设,既然我首先装入了这些类别,只有1个查询将被执行,但配置文件显示不同!那里有 is 1个查询,它从中获取记录
SELECT t0.id AS id1, t0.name AS name2, t0.slug AS slug3, t0.parent_id AS parent_id4
FROM acme_category t0
然后还有另一个查询 : < 坚固> 每一个 < / 坚固 > 的记录 :
SELECT t0.id AS id1, t0.name AS name2, t0.slug AS slug3, t0.parent_id AS parent_id4
FROM omnt_work_category t0 WHERE t0.parent_id = 1
SELECT t0.id AS id1, t0.name AS name2, t0.slug AS slug3, t0.parent_id AS parent_id4
FROM omnt_work_category t0 WHERE t0.parent_id = 1
etc..
为什么呢 我怎么能让它从一开始就装满所有记录呢
谢谢!