forked from joshiket/citilAutomation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbInsDN.php
More file actions
47 lines (43 loc) · 1.48 KB
/
bInsDN.php
File metadata and controls
47 lines (43 loc) · 1.48 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
41
42
43
44
45
46
47
<?php
$file = fopen("dn.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)
{
print_r($wData);
echo "<br>";
try
{
$query = "Insert into wdbt.tblcertifications VALUES(NULL,";
$query .= "" .$wData[0] . ", ";
$query .= "" .$wData[1] . ", ";
$query .= "'" .$wData[2] . "', ";
$query .= "'" .$wData[3] . "', ";
$query .= "'" .$wData[4] . "', ";
$query .= "" .$wData[5] . ", ";
$query .= "'" .$wData[6] . "') ";
echo $query . "<br><br>";
$stmt = $con->prepare($query);
$stmt->execute();
$s++;
}
catch(PDOException $e)
{
$e++;
echo $e->getMessage();
//$con->rollBack();
}//catch
$c++;
}
//$con->commit();
echo "<hr>";
echo "Success : $s" . "<br>";
echo "Error : $e". "<br>";
echo "Total : $c". "<br>";
?>