-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhaksadb.php
61 lines (50 loc) · 1.69 KB
/
haksadb.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$informixdir = getenv("INFORMIXDIR");
$uname = "";
$password= "";
$conn_string = "informix:host=###.###.###.###;service=1200;database=pcuhs;server=centertli;protocol=onsoctcp;
TRANSLATIONDLL=$informixdir/lib/esql/igo4a304.so;
CLIENT_LOCALE=en_US.utf8;DB_LOCALE=en_US.819";
$myhostname='localhost';
$myusername='haksauser';
$mypasswd='haksapass';
$mydbname='haksa';
try {
#print "<li>informixdir = $informixdir</li>\n";
$conn = new PDO($conn_string, $uname, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
print "<li>Got a informix connection</li>\n";
$dbh = new PDO("mysql:host=$myhostname;dbname=$mydbname", $myusername, $mypasswd);
print "<li>Got a mysql connection</li>\n";
$sql = "SELECT * FROM v_paichai_user";
$stmt = $conn->query($sql);
if ( ! $stmt ) {
print "Error in execute: stmt->execute()\n";
print "errInfo[0]=>$err[0]\nerrInfo[1]=>$err[1]\nerrInfo[2]=>$err[2]\n";
}
$total_count=0;
foreach($stmt as $row) {
$userid=$row['USERID'];
$usertype=$row['USERTYPE'];
$pwd=$row['PWD'];
$username=trim(iconv("EUC-KR","UTF-8",$row['USERNAME']));
$surname=mb_substr($username,0,1,"UTF-8");
$firstname=mb_substr($username,1,3,"UTF-8");
$email=trim($row['EMAIL']);
$hp=$row['HP'];
$grade=$row['GRADE'];
$clscode=$row['CLSCODE'];
$sql2="INSERT INTO haksa(userid,usertype,pwd,surname,firstname,email,hp,grade,clscode) VALUES (?,?,?,?,?,?,?,?,?)";
$q=$dbh->prepare($sql2);
$count=$q->execute(array($userid,$usertype,$pwd,$surname,$firstname,$email,$hp,$grade,$clscode));
$total_count++;
}
echo $total_count;
$conn = null;
$dbh = null;
echo 'ok';
} catch (Exception $e) {
print "Exception messsage: {$e->getMessage()}\n";
exit(0);
}
?>