-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbInscustomerMan.php
More file actions
40 lines (35 loc) · 1.34 KB
/
bInscustomerMan.php
File metadata and controls
40 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$file = fopen("customermanager.csv","r");
//$wData = fgetcsv($file, 10000, ",");
//print_r($wData);
$c = 0;
$s = 0;
$e= 0;
$config = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false);
$con = new PDO("mysql:host=localhost;"." dname = wdbt" ." ", "root" ,"root" ,$config);
$con->beginTransaction();
while (($wData = fgetcsv($file, 10000, ",")) !== FALSE)
{
try
{
$config = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false);
$con = new PDO("mysql:host=localhost;"." dname = wdbt" ." ", "root" ,"root" ,$config);
$query = sprintf("INSERT INTO wdbt.tblcustomermanager VALUES(NULL,'%d','%d')",$wData[1],$wData[2]);
echo $query;
$stmt = $con->prepare($query);
$stmt->execute();
$s++;
}
catch(PDOException $e)
{
echo $e->getMessage();
$e++;
}//catch
$c++ ;
}
$con->commit();
echo "<hr>";
echo "Success : $s" . "<br>";
echo "Error : $e". "<br>";
echo "Total : $c". "<br>";
?>