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


i getting following error:

strict (2048): declaration of csvimportbehavior::setup() should compatible  modelbehavior::setup(model $model, $config = array)  [app\plugin\utils\model\behavior\csvimportbehavior.php, line 20] 

i followed tutorial on site: http://www.pronique.com/blog/enable-csv-import-all-controllers-models-cakephp-2

when import csv file, gives following flash message:

successfully imported 0 records book1.csv 

i don't understand why not importing, have error/warning giving?

i looked inside behaviour (csvimportbehaviour.php @ line 20): class csvimportbehavior extends modelbehavior {
not make sense on line 20, that's class declaration, moved down on code , saw following: public function setup(model &$model, $settings = array()) {-- seem me according standards.

to suppress errors/warnings, try to:

  • remove & before $model (not required model object , therefore passed byref)

optionally (see comment @mark):

  • rename $model $model (lowercase)

  • rename $settings $config

i don't know reason not importing records csv, require debugging on side.

alternatives

cakephp has csv datasource part of datasources plug in.

using this, can create model that, in stead of using database, uses csv file source. allows to, example, this;

 $csvdata = $this->mycsvmodel->find('all'); 

which return rows csv file. importing database easy implement saving $csvdata model

links:

https://github.com/cakephp/datasources/tree/2.0 https://github.com/cakephp/datasources/blob/2.0/model/datasource/csvsource.php


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -