开发者

Symfony 1.4 Doctrine fixtures load individual file?

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 tha开发者_开发百科t 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?


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


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 :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜