我遇到了sqlsrv驅動程序的此語法的問題。準備聲明與TS
這只是正常:
$sql = "SELECT * from Table1 WHERE (Table1.Time >= {ts '2017-05-08
00:00:00' } AND Table1.Time < {ts '2017-05-10 00:00:00' })";
$stmt = sqlsrv_query($conn, $sql);
$tbl = "<table>"
while ($row = sqlsrv_fetch_array($stmt)){
$tbl .= "<tr><td>".$row[0]."</td><td>".$row[1]->format('Y-m-d H:i:s')."</td><td align=\"center\">".$row[2]."</td></tr>";
}
$tbl .= "</table>";
echo $tbl;
但這不起作用了所有:
$sql = "SELECT * from Table1 WHERE (Table1.Time >= {ts ? } AND Table1.Time < {ts ? })";
$stmt = sqlsrv_prepare($conn, $sql, array('2017-05-08 00:00:00','2017-05-10 00:00:00'));
$result = sqlsrv_execute($stmt);
$tbl = "<table>"
while ($row = sqlsrv_fetch_array($stmt)){
$tbl .= "<tr><td>".$row[0]."</td><td>".$row[1]->format('Y-m-d H:i:s')."</td><td align=\"center\">".$row[2]."</td></tr>";
}
$tbl .= "</table>";
echo $tbl;
我得到這個錯誤:
An invalid parameter was passed to sqlsrv_execute. [message] => An invalid parameter was passed to sqlsrv_execute.)
有沒有一種正確的方法將日期變量傳遞給{ ts ? }
聲明?
當你得到一個空白頁面時,啓用PHP中的錯誤記錄。您應該使用臨時引擎從數據庫分離UI。使用參數工作不同 - 刪除{ts?}並只放一個?在位置。 –