Yii Framework Forum: Compare Csv File Records To Database Table Records - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Compare Csv File Records To Database Table Records Rate Topic: -----

#1 User is offline   oliveira 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 20-January 14

Posted 28 January 2014 - 11:42 AM

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?
0

#2 User is offline   waitforit 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 09-February 11

Posted 28 January 2014 - 12:39 PM

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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users