File "test_data.php"
Full path: /www/shinmoji/wg2/graph/test_data.php
File size: 2.18 KiB (2229 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
//===============================================
// CommonUtilities
// 備考 :
// 更新 : 2012/11/29 KMK-Teraoka
//===============================================
$SCRIPT_TITLE = "運行管理システム 新門司";
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";
$HOST = "192.168.100.153";
$DB = "cnbs";
$USER = "postgres";
$PASS = "am#71ZJ*";
// ===============================================
// GD処理準備
// 備考 :
// 更新 : 2010/09/08 KMK T.Teraoka
// ===============================================
$img = imagecreatetruecolor(500,500); //パレットの作成
$font1 = "/usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf";
// 使用色の準備
$Black = imagecolorallocate($img, 0,0,0);
$White = imagecolorallocate($img, 255, 255, 255);
$Red = imagecolorallocate($img, 255, 0, 0);
imagefill($img, 0, 0, $White);
//================================================
// データベース接続
// 備考 :
// 更新 : 2012/11/29 KMK-Teraoka
//================================================
$conn = pg_connect("
host = ". $HOST. "
dbname = ". $DB. "
user = ". $USER. "
password= ". $PASS. "
");
if (!$conn)
{
throw new Exception("データベースへの接続に失敗しました");
}
$sql = "SELECT * FROM shinmoji.wg_avg_t ORDER BY pid desc;";
$res = pg_query($conn,$sql)or die("SQL ERROR!!<br />". $sql.pg_last_error());
$DataCt = pg_num_rows($res);
print $sql ."<BR>";
print $DataCt ."<BR>";
$now_time = time();
for($i = 0;$i < $DataCt;$i++)
{
$up_time =date("Y-m-d H:i:s" ,$now_time - $i * 4);
$row = pg_fetch_array($res,$i);
$Up = "UPDATE shinmoji.wg_avg_t SET regdate='" .$up_time ."' WHERE pid = " .$row[0];
$resu = pg_query($conn,$Up)or die("SQL ERROR!!<br />". $Up.pg_last_error());
}
print "完了";
//===============================================
// Postgresql終了処理
// 備考 :
// 更新 : 2012/10/19 KMK-Teraoka
//===============================================
pg_close($conn);
//===============================================
// HTML終了処理
// 備考 :
// 更新 : 2012/10/18 KMK-Teraoka
//===============================================
//print "</body>";
//print "</html>";
?>