--- a/admin/partialdata/import.php +++ b/admin/partialdata/import.php @@ -1,9 +1,13 @@ "; + flush(); $row = 1; + $success = 0; + $dupes = 0; $handle = fopen($fpath, "r"); //"t" mode string translates windows line breaks to unix $datamapping0507 = array( @@ -16,7 +20,8 @@ "Title" => "description", "Category" => "category", "ATM ID" => "atmID", - "LastUpdated" => "", + "Supplier Name" => "supplierName", + "LastUpdated" => "amendDate", "" => "" ); $headers; @@ -32,7 +37,7 @@ "value", "atmID", "supplierName", - "LastUpdated" + "amendDate" ); if ($tablename == "contractnotice") { $contractNoticeInsertQ = 'INSERT INTO contractnotice ("' . implode('" , "', $contractNoticeFields) . '") VALUES ( '; @@ -50,7 +55,7 @@ } elseif ($row > 3) { if ($num > count($datamapping0507)) { - die("Error in data import; data mapping fields out of bounds or changed
" . $fname . print_r($data)); + die("Error in data import; data mapping fields out of bounds or changed
" . $fname . "data:" .$num. print_r($data ,true). "mapping:" . count($datamapping0507). print_r($datamapping0507 ,true)); } $contractNoticeInsert = Array(); $contractNoticeInsert[] = $fpath; @@ -98,6 +103,7 @@ $contractNoticeInsertQ->execute($contractNoticeInsert); $errors = $conn->errorInfo(); if ($errors[1] == 7 && strpos($errors[2], "duplicate key")) { + $dupes++; } elseif ($errors[1] == 0) { $success++; @@ -116,6 +122,9 @@ $row++; } fclose($handle); + echo " $dupes duplicate records
"; + echo " $success records successfully created
"; + flush(); return $success; } $path = './'; @@ -129,6 +138,7 @@ while (false !== ($fname = readdir($dhandle))) { if (($fname != '.') && ($fname != '..')) { echo "$fname " . filesize($path . $fname) . " " . date("c", filemtime($path . $fname)) . "
"; + processFile($path . $fname, "contractnotice"); } } } @@ -136,11 +146,9 @@ else { $success = 0; $fname = $_REQUEST["fname"]; - echo " ============== $fname ==============
"; - flush(); + $success+= processFile($path . $fname, "contractnotice"); - echo "
$success records successfully created"; - flush(); + } ?>