I have a site that uses both Doctrine Migrations and Fixtures successfully (awesome features!), however I am having a small issue.
我有一个成功使用Doctrine Migrations和Fixtures的网站(很棒的功能!),但是我遇到了一个小问题。
I have added a table and a new foreign key field to that table in an existing entity. The migration populates the new table with its initial values.
我在现有实体中为该表添加了一个表和一个新的外键字段。迁移使用其初始值填充新表。
In my fixture that loads data for the table with the foreign key, I need to set the field to one of the values created in the migration, but I can't seem to get any entities out of that repository.
在我使用外键加载表的数据的fixture中,我需要将字段设置为迁移中创建的值之一,但我似乎无法从该存储库中获取任何实体。
Any ideas why that would be happening, or a suggestion as to how I should be doing this differently.
任何想法为什么会发生,或建议我应该如何不同地做这件事。
The fixture implements the ContainerAwareInterface
so that I have access to the entities repository, but doing:
fixture实现了ContainerAwareInterface,以便我可以访问实体存储库,但是:
$repo = $this->container->get('doctrine')
->getRepository('myCoreBundle:StoryStatus');
$statuses = $repo->findAll();
print_r($statuses);
returns nothing, even though I can see there are values in the DB at this point.
什么都不返回,即使我可以看到此时DB中有值。
1 个解决方案
#1
0
Figured it out. Bit of stupidity on my part. Loading the fixtures was clearing the database of course, so it would never find any entities :). Need to implement a fixture to create them again.
弄清楚了。对我来说有点愚蠢。加载灯具当然是清理数据库,因此它永远不会找到任何实体:)。需要实现一个夹具来再次创建它们。
#1
0
Figured it out. Bit of stupidity on my part. Loading the fixtures was clearing the database of course, so it would never find any entities :). Need to implement a fixture to create them again.
弄清楚了。对我来说有点愚蠢。加载灯具当然是清理数据库,因此它永远不会找到任何实体:)。需要实现一个夹具来再次创建它们。