簡體   English   中英

PHP-PDO不更新時間()

[英]php - PDO not updating time()

我在有人在我的論壇中發表回復時執行的PDO查詢存在問題:

$time= time();  


$s = $dbh->prepare("UPDATE forum_topics SET last_post_user=:user, last_post_userid=:userid, last_post_time=:time, posts=posts+1 WHERE topic_id=:topicid");
                $s->bindParam(':user', $userdata['username']);
                $s->bindParam(':userid', $userid);
                $s->bindParam(':time', $time);
                $s->bindParam(':userid', $userid);
                $s->bindParam(':topicid', $topicid);
                            try {
                    $s->execute();
                }
                catch(PDOException $e) {
                    die($e->getMessage());
                }

上面的查詢實際上確實更新了我的數據庫。.所有字段,期望:time得到更新。

數據庫中last_post_time的結構為int(20)

我不知道為什么不進行更新-有人可以看到任何問題嗎? 我沒有收到任何錯誤。

幾個問題:您有例外嗎? 或者只是DB中的last_post_time為空(默認值)? $time= time()將時間戳分配給$time

您也可以嘗試將:time替換為:post_time

$s = $dbh->prepare("UPDATE forum_topics SET last_post_user=:user, last_post_userid=:userid, last_post_time=:post_time, posts=posts+1 WHERE topic_id=:topicid");
                $s->bindParam(':user', $userdata['username']);
                $s->bindParam(':userid', $userid);
                $s->bindParam(':post_time', $time);
                $s->bindParam(':userid', $userid);
                $s->bindParam(':topicid', $topicid);
                            try {
                    $s->execute();
                }
                catch(PDOException $e) {
                    die($e->getMessage());
                }

您還可以檢查數據庫的內部日志,以檢查內部是否沒有錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM