我正在尝试从 MS SQL Server 获取按当前时间过滤的列数据。单元格有datetime
格式。但我得到空洞的回应。哪里出错了?
<?php
$serverName = ''; // server name
$cinfo = array(
"Database" => "", // database
"UID" => "", // user
"PWD" => "" // pass
);
$conn = sqlsrv_connect($serverName, $cinfo);
if ($conn) {
echo "connected" . "<br/>";
$datetimenow = current_time("d.m.Y H:i"); // wordpress function
echo $datetimenow . "<br/>"; // 30.05.2020 14:10
if (($result = sqlsrv_query($conn, "SELECT * FROM dbo.GorElectroTrans WHERE GPS_datetime=$datetimenow")) !== false) {
while ($obj = sqlsrv_fetch_object($result)) {
echo $obj->Longitude . '<br />';
}
}
} else {
die(print_r(sqlsrv_errors(), true));
}
?>
ITMISS