php - Yii:Upload CSV file to database -


i'm trying save csv file database , finding issues it.

controller:

$mod = new csv; if(isset($_post['csv'])) { $mod->attributes=$_post['csv']; if(!empty($_files['csv']['tmp_name']['csv'])) { $file = cuploadedfile::getinstance($mod,'csv'); $fp = fopen($file->tempname, 'r'); if($fp) {  {  $line = fgetcsv($fp, 1000, ",");  echo $line[0];   echo $line[1];    $mod['mobile'] = $line[0];  $mod['name'] = $line[1];  $mod->insert();   }  while( ($line = fgetcsv($fp, 1000, ";")) != false);  }  }} 

i'm able store first record of csv file. other records stored null. dont know i'm missing here

http://www.yiiframework.com/wiki/442/upload-csv-file/

  $mod->save(); 

instead of

  $mod->insert(); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -