Symfony 1.4 Doctrine 装置加载单个文件?

发布于 2024-12-07 10:03:43 字数 223 浏览 0 评论 0原文

我有一个工作应用程序,我想添加一些固定装置,但实际上我想做的就是加载新的固定装置文件。

当我运行

php symfony doctrine:data-load

它是否重新输入数据库中已有的数据时。如果没有,我想我可以直接调用它,它只会添加自上次以来的新装置。

如果它确实再次输入所有数据,那么有没有办法隔离特定夹具文件上的数据加载?

I've got a working app and I want to add some fixtures but really all I want to do is load in the new fixture file.

When i run the

php symfony doctrine:data-load

Does it re-enter data that is already in the database. If not I assume I can just call this and it will only add new fixtures since last time.

If it does enter all data again then is there a way to isolate data load on a specific fixture file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌若浮生 2024-12-14 10:03:44

在命令前添加字符串“help”即可获得详细说明:

php symfony help doctrine:data-load
...


 If you want to load data from specific files or directories, you can append
 them as arguments:

   ./symfony doctrine:data-load data/fixtures/dev data/fixtures/users.yml

With the string "help" befor the command you become a detailed description:

php symfony help doctrine:data-load
...


 If you want to load data from specific files or directories, you can append
 them as arguments:

   ./symfony doctrine:data-load data/fixtures/dev data/fixtures/users.yml
叶落知秋 2024-12-14 10:03:44

您可以做您想做的两件事 - 您需要创建一个新任务来执行此操作...

这将加载到单独的装置文件中:

Doctrine_Core::loadData('/path/to/data.yml');

这会将固定文件附加到当前数据:

Doctrine_Core::loadData('/path/to/data.yml', true);

所以只需创建一个新任务 - 访问数据库连接并根据您想要执行的操作运行这些命令之一

抱歉...也许我应该正确阅读手册...

您确实可以使用当前命令附加和/或使用特定文件。

Usage:
 symfony doctrine:data-load [--application[="..."]] [--env="..."] [--append] [dir_or_file1] ... [dir_or_fileN]

Arguments:
 dir_or_file    Directory or file to load

Options:
 --application  The application name (default: 1)
 --env          The environment (default: dev)
 --append       Don't delete current data in the database

Description:
 The doctrine:data-load task loads data fixtures into the database:

   ./symfony doctrine:data-load

 The task loads data from all the files found in data/fixtures/.

 If you want to load data from specific files or directories, you can append
 them as arguments:

   ./symfony doctrine:data-load data/fixtures/dev data/fixtures/users.yml

 If you don't want the task to remove existing data in the database,
 use the --append option:

   ./symfony doctrine:data-load --append

再次为误导您而道歉...但想想 - 您现在已经学会了如何编写任务:-)

You can do both of the things you want - you will need to create a new task to do it though ...

This will load in an individual fixtures file :

Doctrine_Core::loadData('/path/to/data.yml');

This will append the fixtures file to the current data :

Doctrine_Core::loadData('/path/to/data.yml', true);

So just create a new task - access the database connection and run one of these commands depending on what you want to do

Apologies ... perhaps I should read the manual properly ...

You can indeed use the current command to append and/or use a specific file.

Usage:
 symfony doctrine:data-load [--application[="..."]] [--env="..."] [--append] [dir_or_file1] ... [dir_or_fileN]

Arguments:
 dir_or_file    Directory or file to load

Options:
 --application  The application name (default: 1)
 --env          The environment (default: dev)
 --append       Don't delete current data in the database

Description:
 The doctrine:data-load task loads data fixtures into the database:

   ./symfony doctrine:data-load

 The task loads data from all the files found in data/fixtures/.

 If you want to load data from specific files or directories, you can append
 them as arguments:

   ./symfony doctrine:data-load data/fixtures/dev data/fixtures/users.yml

 If you don't want the task to remove existing data in the database,
 use the --append option:

   ./symfony doctrine:data-load --append

Once again apologies for misleading you ... but just think - you have learned how to write tasks now :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文