File "temrinal.php"
Full path: /www/ansys/qgis/000_nasu2/mapref/temrinal.php
File size: 1.46 KiB (1492 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
try
{
$output = array();
$addIndex = 0;
$WORK_STATUS = 0;
$enableSec = 600;
$enableDateTime = date("Y-m-d H:i:s", time() - $enableSec);
//データベース接続
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$conn = pg_connect("
host = ". $HOST. "
dbname = ". $DB. "
user = ". $USER. "
password= ". $PASS. "
");
$output[$addIndex++] = "0";
$sql = "SELECT * FROM qgis.ts_terminal";
// $sql = "SELECT * FROM qgis.ts_his_measure";
$sql .= " WHERE app_id='18'";
$sql .= " AND const_id='1'";
// $sql .= " AND mesdatetime >= '". $enableDateTime. "'";
if (strcmp($WORK_STATUS, 0) != 0)
// $sql .= " AND work_status='". $WORK_STATUS. "'";
$sql .= " ORDER BY regdatetime limit 5;";
$res = pg_query($conn, $sql);
if (!($resList = pg_query($conn, $sql)))
throw new Exception("");
$numTemrinal = pg_num_rows($res);
$fpo = fopen("test_log.txt","a");
for($iCount = 0; $iCount < $numTemrinal; $iCount++)
{
$row = pg_fetch_array($res, $iCount);
$output[$addIndex++] = $row["android_id"]. ",". $row["lon"]. ",". $row["lat"]. ",". $row["work_status"];
// $output[$addIndex++] = "TEST_A". ",". $row["lon"]. ",". $row["lat"]. ",". "0";
}
$numoutput = count($output);
fwrite($fpo,$numoutput ."\n");
for($iCount = 0; $iCount < $numoutput; $iCount++)
{
if ($iCount > 0)
print "\\n";
print $output[$iCount];
fwrite($fpo,$output[$iCount] ."\n");
}
fclose($fpo);
}
catch(Exception $exc)
{
print "";
}
?>