-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_info_to_pgsql.php
More file actions
executable file
·48 lines (40 loc) · 1.28 KB
/
write_info_to_pgsql.php
File metadata and controls
executable file
·48 lines (40 loc) · 1.28 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
48
<?php
$dir = opendir('.');
$this_name = basename(__FILE__);
$matchs = array();
$str = __FILE__;
$conn = @pg_connect ( "host=localhost dbname=kakou user=postgres password=postgres" );
$reg = '/([^S]+([^\/]+))\/\D+(\/\d+)+\/(\D+)?\//';
if(preg_match($reg, $str, $matchs))
{
print_r($matchs);
}
if(!$conn)
{
echo pg_last_error()."\n";
pg_close($conn);
$conn = NULL;
exit;
}
else
{
echo "pgsql connect successed!\n";
}
$sql_cmd = "insert into cltx (fxbh,hphm,hpzl,hpys,jgsj,clsd,tjtp,qmtp,hptp,clxs,cdbh,wzdd,kkbh,tpwz,scbz,tztp,csys,sub_hphm) values('test','-','0','-',to_timestamp($1,'yyyy\mm\dd\hh24miss'),6,$2,$3,'0|0|0,0,0,0|0,0,0,0|',80,'3',$4,'hdk016','hddj-imgserv01','0','no_data','0','-')";
$result = pg_prepare($conn, 'insertData', $sql_cmd);
if(!$result)
{
echo pg_last_error()."\n";
}
while(false !== ($file = readdir($dir)))
{
if($file[0] === '.' || $file === $this_name)## strcmp($file, $this_name))
continue;
$path = realpath($file);
$ins_p = str_replace('/', '\\', str_replace($matchs[1].'/', "", $path));
$date = substr($ins_p, 10, 10).'\\'.str_split(basename($path), 6)[0];
echo $ins_p."\n".$date."\n";
$res = pg_execute($conn, "insertData", array($date, $ins_p, $matchs[2], $matchs[4]));
}
closedir($dir);
?>