简体   繁体   English

如何在fuelphp中构建Fixtures?

[英]How to build Fixtures in fuelphp?

I am using FuelPHP 1.8 and I am searching a way to write fixtures for fill my databases in a initial stage.我正在使用 FuelPHP 1.8,我正在寻找一种方法来编写固定装置以在初始阶段填充我的数据库。

I see this question about DB seeding in FuelPHP in FuelPHP, but I don't know if it applies too for fixtures.在 FuelPHP中看到有关在 FuelPHP中进行数据库播种的问题,但我不知道它是否也适用于装置。

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.然后,您可以遍历该数组,为 eash 行构造一个 DB::insert() 对象,然后执行该对象。

Using the ORM isn't advised, as that caches objects by default, so it isn't suitable for loading large datasets.不建议使用 ORM,因为它默认缓存对象,因此它不适合加载大型数据集。 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() .如果您需要使用 ORM,例如创建关系,则需要通过在调用save()之前添加from_cache(false)来禁用对象缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM