Compare Csv File Records To Database Table Records

Hello all,

I want to compare if the table already has a record with the same name as in the csv file, if it has already the record it just simply updates it…




$cols = str_getcsv($line, ';', '"');//csv file

 $fields = ImportationDetail::model()->findAll();

$modelA = $modelApp::model()->findByAttributes(array($fields[] => $cols[]));


 if (!$model)

$model = new $args[0];




But im getting this error


Illegal offset type

$modelA = $modelApp::model()->findByAttributes(array($fields[] => $cols[]));

Can you help to compare the two objects?

How about taking an md5sum of a couple of the fields from the csv and table and comparing?

I don’t know your schema but I consider it doubtful that you need to compare ALL the fields?