Sqlite可以正确提供结果,但是当我在PHP中使用代码时,它会警告SQLite3::query()
:无法准备声明。
此警告是由于使用OVER(ORDER BY)
命令引起的。如果我删除此php,则显示结果,但是当我使用OVER时,它会给出错误。而且我不知道如何解决这个问题。
$sql="SELECT trandate, type, particulars, custid, custname, debit, credit,
SUM(CASE WHEN trandate = '$opdate'
THEN $totop+debit
ELSE debit-credit
END)
OVER(ORDER BY date(substr(trandate, 7, 4)
|| '-' || substr(trandate, 4, 2)
|| '-' || substr(trandate, 1, 2)
) ASC
) AS balance, notes
FROM inboundtrans
WHERE custid ='$customer' and type!='$type'
ORDER BY datetime(substr(trandate, 7, 4)
|| '-' || substr(trandate, 4, 2)
|| '-' || substr(trandate, 1, 2)) ASC";
$query = $con->query($sql);
while ($row = $query->fetchArray(SQLITE3_ASSOC)) {
echo "
<tr>
<td>{$row['trandate']}</td>
<td>{$row['type']}</td>
<td>{$row['particulars']}</td>
<td>{$row['debit']}</td>
<td>{$row['credit']}</td>
<td>{$row['balance']}</td>
<td>{$row['notes']}</td>
</tr>\n";
}
显示错误
警告:SQLite3 :: query():无法准备语句:1,在“(”附近: 第188行的C:\ My Themes \ storelite \ www \ ledView.php中的语法错误
致命错误:未捕获错误:调用成员函数fetchArray() C:\ My Themes \ storelite \ www \ ledView.php:190中的布尔值堆栈跟踪:#0 {main}在第190行的C:\ My Themes \ storelite \ www \ ledView.php中抛出