如何在fuelphp中构建夹具?

时间:2016-10-03 23:31:04

标签: php module migration fixtures fuelphp

我正在使用FuelPHP 1.8,我正在寻找一种方法来编写灯具,以便在初始阶段填充我的数据库。

我在FuelPHP中看到this question about DB seeding in FuelPHP,但我不知道它是否也适用于灯具。

1 个答案:

答案 0 :(得分:1)

The current Fuel version doesn't have any provisions for either seeding nor fixtures.

It means you need to create a method of loading data (a task perhaps) from somewhere, and maniplate it so that you end up with a multi-dimensional assoc array where every array item represents a record. You can then loop over that array, construct a DB::insert() object for eash row, and execute that.

Using the ORM isn't advised, as that caches objects by default, so it isn't suitable for loading large datasets. If you need to use the ORM, for example to create relations, you need to disable the object cache, by adding from_cache(false) before you call save().