CsvImport
class CsvImport
Class CsvImport Import Helper to use CSV files for model generation. The helper loops through all rows, generates a new model and passed the columns as property. Use the provided set_before_model_save() and set_after_model_save() to add custom code to be executed during the creation, e.g. if you need to call a custom model function or you need to convert data prior saving.
Example: $seed_instance = $XF->im->get_instance('my_groups'); $seed = new CsvImport($seed_instance, 'group'); $seed->set_source(dirname(FILE).'/data/group.csv'); $seed->import();
Methods
Runs the import process and generates the models
Executed for each generated model AFTER saving it
Executed for each generated model BEFORE saving it
Sets the CSV File which should be loaded
Details
at line 66
__construct(Core $seed_instance, string $model_name)
CsvImport constructor.
at line 103
import(string $delimiter = ';')
Runs the import process and generates the models
at line 92
set_after_model_save($callback)
Executed for each generated model AFTER saving it
at line 84
set_before_model_save($callback)
Executed for each generated model BEFORE saving it
at line 76
set_source(string $csv_file)
Sets the CSV File which should be loaded