<?php
$gett = $_GET["q"];//获取数据
$selectTimeMin = $_GET['selectTimeMin'];
$selectTimeMax = $_GET['selectTimeMax'];
ini_set("precision", "3");  //浮点数小数位数
   class MyDB extends SQLite3
   {
      function __construct()
      {
			//$this->open('C:/Users/Administrator/Desktop/workFile/ElecWaterPrj/水文协议SL651 配置软件20220120/DB/SL651.sqlite.db3');
			$this->open('./Debug/DB/SL651.sqlite.db3');
      }
   }
   $con = new MyDB();
   if(!$con){
      echo $con->lastErrorMsg();
   } 
   
// 选择数据库
$sql="SELECT * FROM dataInfo WHERE dataTime > '$selectTimeMin' and dataTime < '$selectTimeMax' and devID = '".$gett."' ORDER by `dataTime` DESC LIMIT 30;";
$result = $con->query($sql);
//echo $sql;
if (!$result) {
    printf("Error: SELECT DB ERR\n");
	$con->close();
    exit();
}

echo "<table border='1'>
<tr>
<th>序号</th>
<th>采集时间</th>
<th>上报时间</th>
<th>设备ID</th>
<th>功能码</th>
<th>数值</th>
</tr>";
//SELECT 操作
while($row = $result->fetchArray(SQLITE3_ASSOC) )
{
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['dataTime'] . "</td>";
    echo "<td>" . $row['reportTime'] . "</td>";
	echo "<td>" . $row['devID'] . "</td>";
	echo "<td>" . $row['pcode'] . "</td>";
	echo "<td>" . $row['pvalue'] . "</td>";
    echo "</tr>";
}

$con->close();
 ?>