我正在尝试将csv文件的数据上传到我的数据库中。
ProgressDialog progressDialog = new ProgressDialog(activity, false, "Progress loading message...(0%)");
progressDialog.show();
progressDialog.setProgressMessage("Progress loading message changed .... (10%)");
添加slash_recursive函数
public function uploadExcel()
{
DB::table('members')->delete();
$filename = Input::file('import_file')->getRealPath();
$file = fopen($filename, "r");
$count = 0;
while (($emapDataUnescaped = fgetcsv($file, 10000, "\t")) !== FALSE) {
$emapData = self::addslashes_recursive($emapDataUnescaped);
$count++;
if($count>1) {
DB::statement("INSERT INTO `members` (
member_title,
member_first_name,
member_name_affix,
member_last_name,
member_private_address,
member_private_zip_code,
member_private_location,
member_private_phone,
member_private_mobile,
member_private_fax,
member_private_mail,
member_business_position,
member_business_name,
member_business_address,
member_business_zip_code,
member_business_location,
member_business_area_code,
member_business_phone,
member_business_fax,
member_business_mobile,
member_business_mail,
member_join_date,
extra
) VALUES (
'$emapData[0]',
'$emapData[1]',
'$emapData[2]',
'$emapData[3]',
'$emapData[4]',
'$emapData[5]',
'$emapData[6]',
'$emapData[7]',
'$emapData[8]',
'$emapData[9]',
'$emapData[10]',
'$emapData[11]',
'$emapData[12]',
'$emapData[13]',
'$emapData[14]',
'$emapData[15]',
'$emapData[16]',
'$emapData[17]',
'$emapData[18]',
'$emapData[19]',
'$emapData[20]',
'$emapData[21]',
'$emapData[22]'
)");
}
}
return redirect('index');
}