Strict (2048): Declaration of CsvImportBehavior::setup() should be compatible with ModelBehavior

大憨熊 提交于 2019-12-06 05:22:45

To suppress the errors/warnings, try to:

  • remove the & before $Model (not required as Model is an object and therefore already passed byref)

Optionally (see comment by @mark):

  • rename $Model to $model (lowercase)

  • rename $settings to $config

I don't know the reason for not importing records from the CSV, that will require debugging on your side.

Alternatives

CakePHP also has a CSV dataSource as part of the datasources plug in.

Using this, you can create a Model that, in stead of using a database, uses a CSV file as its source. This allows you to, for example, do this;

 $csvData = $this->MyCsvModel->find('all');

Which will return all rows from the CSV file. Importing this into your database will be easy to implement by saving $csvData to another model

Links:

https://github.com/cakephp/datasources/tree/2.0 https://github.com/cakephp/datasources/blob/2.0/Model/Datasource/CsvSource.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!