我有一個工作的應用程序,我想添加一些燈具,但真正我想要做的就是加載新的燈具文件。Symfony 1.4 Doctrine fixture加載單個文件?
當我運行
php symfony doctrine:data-load
它重新輸入數據已在數據庫中。如果不是這樣,我會認爲我可以這麼稱呼它,並且它只會在上次添加新的燈具。
如果它再次輸入所有數據,那麼是否有辦法隔離特定夾具文件上的數據加載?
我有一個工作的應用程序,我想添加一些燈具,但真正我想要做的就是加載新的燈具文件。Symfony 1.4 Doctrine fixture加載單個文件?
當我運行
php symfony doctrine:data-load
它重新輸入數據已在數據庫中。如果不是這樣,我會認爲我可以這麼稱呼它,並且它只會在上次添加新的燈具。
如果它再次輸入所有數據,那麼是否有辦法隔離特定夾具文件上的數據加載?
字符串「幫助」之前打個電話成爲一個詳細說明的命令:
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
你都可以做你想做的事情 - 你將需要
create a new task做雖然它...
這將在一個單獨的固定裝置裝載文件:
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
再次表示歉意誤導你...只是覺得 - 你已經學會了如何編寫任務現在:-)
謝謝,但你是建議做一個PHP文件,並將其中的代碼,並從命令行調用它?正如我說的,我通常使用命令行調用:php symfony doctrine:data-load –
您需要創建一個新的任務 - php symfony生成任務等...教條:數據加載實際上是一項任務 - 您可以創建這些 - 將你的命令放在任務中,然後運行它 – ManseUK
@DerekOrgan http://www.symfony-project.org/more-with-symfony/1_4/en/13-Leveraging-the-Power-of-the-Command線條#chapter_13_tasks_at_a_glance – ManseUK