我创建了这个查询 sqlite 数据库的 php 脚本,如下所示:
$r = $db->prepare("SELECT * FROM logs WHERE ip=?;");
$r->bindValue(1, $ip, PDO::PARAM_STR);
$r->execute();
if($r->fetchColumn() >= 1) {
echo "contains columns.. <br />";
$result = $r->fetchAll();
foreach ($result as $log) {
echo "in loop";
$log_ip = $log['ip'];
$log_userAgent = $log['userAgent'];
$log_hits = $log['hits'];
$log_hits = $log_hits++;
echo "hits " . $log_hits;
$hitUp = $db->prepare("UPDATE logs SET hits = ? WHERE ip = ?;");
$hitUp->bindValue(1, $log_hits, PDO::PARAM_INT);
$hitUp->bindValue(2, $ip, PDO::PARAM_STR);
$hitUp->execute();
}
但是,$r->fetchAll();
正在返回一个空数组。
我 100% 确定该行存在并且 $ip 是 127.0.0.1:
sqlite> select * from logs;
1|127.0.0.1|1|Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.54.16 (KHTML, like Gecko) Version/5.1.4 Safari/534.54.16
任何帮助是极大的赞赏