cakephp3でfixtureをdefaultのデータベースから作成する方法のメモ。
cakephp2だと、対話形式でこれが出来たけど、cakephp3ではbakeする時にパラメータを付ける。
-n オプションの100を10とかにすれば、10件分だけ作る。
オプションの一覧は下記。
cakephp2だと、対話形式でこれが出来たけど、cakephp3ではbakeする時にパラメータを付ける。
bin/cake bake fixture -r -n 100 -f -s モデル名でOK。
-n オプションの100を10とかにすれば、10件分だけ作る。
オプションの一覧は下記。
--conditions The SQL snippet to use when importing records.
(default: 1=1)
--connection, -c The datasource connection to get data from.
(default: default)
--count, -n When using generated data, the number of records to
include in the fixture(s). (default:
1)
--force, -f Force overwriting existing files without prompting.
--help, -h Display this help.
--plugin, -p Plugin to bake into.
--quiet, -q Enable quiet output.
--records, -r Generate a fixture with records from the non-test
database. Used with --count and --conditions to limit
which records are added to the fixture.
--schema, -s Create a fixture that imports schema, instead of
dumping a schema snapshot into the fixture.
--table The table name if it does not follow conventions.
--theme, -t The theme to use when baking code. (choices:
Bake|Migrations)
--verbose, -v Enable verbose output.
スポンサーサイト