日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

replace into mysql去重_上传 phpexcel 类 入库并入库前去重

發布時間:2024/10/8 数据库 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 replace into mysql去重_上传 phpexcel 类 入库并入库前去重 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

upload.html???頁面

upload.php頁面<?php

require_once?"../upload/PHPExcel_1.8.0_doc/Classes/PHPExcel/IOFactory.php";

$object?=new??PHPExcel();

$filePath?=$_FILES["file"]["tmp_name"];

$fileType?=?PHPExcel_IOFactory::identify($filePath);?//文件名自動判斷文件類型

$objReader?=?PHPExcel_IOFactory::createReader($fileType);

$objPHPExcel?=?$objReader->load($filePath);

$currentSheet?=?$objPHPExcel->getSheet(0);?//第一個工作簿

$allRow?=?$currentSheet->getHighestRow();?//行數

/**取得最大的列號*/

$allColumn?=?$currentSheet->getHighestColumn();

for($rowIndex=2;$rowIndex<=$allRow+1;$rowIndex++){

if($objPHPExcel->getActiveSheet()->getCell("A".$rowIndex)->getValue()){

if($objPHPExcel->getActiveSheet()->getCell("A".$rowIndex)->getValue()){

$hba=strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("A".$rowIndex)->getValue()));

$hbb=strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("B".$rowIndex)->getValue()));

$new_arr[]=

‘(\‘‘.$hba.‘\‘,‘.

"‘".($hbb.‘‘)."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("C".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("D".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("E".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("F".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("G".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("H".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("I".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("J".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("K".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("L".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("M".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("N".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("O".$rowIndex)->getValue()))."‘".‘,‘.

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("P".$rowIndex)->getValue()))."‘".‘,‘.

//strtotime(date(‘Y-m-d?H:i:s‘)).",".

"‘".strtoupper(trim($objPHPExcel->getActiveSheet()->getCell("Q".$rowIndex)->getValue()))."‘".‘)‘;

}

}//此處A-Q表示??表格的列到哪個字母?這里就寫到哪個字母?(根據自身的需求)

mysql_connect("localhost","root","root");

mysql_select_db("count");

mysql_query("SET?AUTOCOMMIT=0");//設置為不自動提交,因為MYSQL默認立即執行

mysql_query("BEGIN");//開始事務定義

mysql_query("set?names?utf8");

foreach($new_arr?as?$vv){

$sql=mysql_query("replace?into?wangyou?(addtime,sp_code,sp_name,yw_code,yw_name,month_payuser,

month_xzuser,day_payuser,day_pay,day_paycs,month_pay,qsst_payuser,content_class,day_paybl,day_syuser,month_syuser,qsst_syuser)?values?$vv");

if(!$sql){

mysql_query("ROOLBACK");//判斷執行失敗回滾

}

}

mysql_query("COMMIT");//執行事務

}

$count=mysql_num_rows(mysql_query("select?*?from?wangyou"));

$chongfu=$allRow-$count-1;

echo?"網游管控成功入庫".$count."條".","."重復".$chongfu."條";

?>

這里的去重????用到了mysql里的唯一索引?unique???當然用到unique時相應的sql就變成replace?into

本文出自 “php開發” 博客,轉載請與作者聯系!

原文:http://872520828.blog.51cto.com/9822540/1604774

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的replace into mysql去重_上传 phpexcel 类 入库并入库前去重的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。