當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Thread::updateUpdateTime方法代碼示例

本文整理匯總了PHP中Thread::updateUpdateTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP Thread::updateUpdateTime方法的具體用法?PHP Thread::updateUpdateTime怎麽用?PHP Thread::updateUpdateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Thread的用法示例。


在下文中一共展示了Thread::updateUpdateTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 public static function create($thread_id, $title, $content, $date, $time, $author_id, $input_type)
 {
     $db = getDatabase();
     // (1) insert into post_22
     $dt = new DateTime();
     $current_timestamp = $dt->getTimestamp();
     $q = "INSERT INTO post_" . $thread_id . " (" . self::KEY_TITLE . "," . self::KEY_CONTENT . "," . self::KEY_DATE . "," . self::KEY_TIME . "," . self::KEY_AUTHOR . "," . self::KEY_INPUT_TYPE . "," . self::KEY_MODIFIED_TIME . "," . self::KEY_CREATED_TIME . " " . ")VALUES(" . ":title," . ":content," . ":date," . ":time," . ":author_id," . ":input_type," . $current_timestamp . "," . $current_timestamp . " " . ")";
     try {
         $stmt = $db->prepare($q);
         $stmt->bindParam(':title', $title);
         $stmt->bindParam(':content', $content);
         $stmt->bindParam(':date', $date);
         $stmt->bindParam(':time', $time);
         $stmt->bindParam(':author_id', $author_id);
         $stmt->bindParam(':input_type', $input_type);
         $stmt->execute();
         $lastInsertId = $db->lastInsertId(self::KEY_ID);
         // (2) update post_list update time & date
         $thread = new Thread();
         $thread->initWithId($thread_id);
         $thread->updateUpdateTime($time, $date, $current_timestamp);
         // (3) get the last insert post
         $post = new Post();
         $post->initWithId($thread_id, $lastInsertId);
         return $post;
     } catch (PDOException $ex) {
         Utils::HandlePDOException($ex);
     }
     return null;
 }
開發者ID:plainbanana,項目名稱:eicforum,代碼行數:30,代碼來源:post.php

示例2: delete

 public static function delete($thread_id, $post_id)
 {
     // begin
     if ($_SESSION[KEY_SESSION][Account::KEY_USERNAME] == "guest") {
         Utils::showNoPermissionPage();
         die;
     }
     // end
     $thread = new Thread();
     $thread->initWithId($thread_id);
     $post = $thread->getPostById($post_id);
     if (!empty($_GET["confirm"]) && $_GET["confirm"] == "true") {
         // delete post, if current person is thread's host, delete thread as well
         if ($post->getAuthor()->getId() == $_SESSION[KEY_SESSION][Account::KEY_ID]) {
             $redirect_to = "/thread/";
             // it means host thread
             if ($post->isHost()) {
                 $thread->delete();
                 $post->delete();
             } else {
                 $post->delete();
                 $latest_update = Post::getLastModifiedPost($thread_id)->getModifiedTime();
                 $dt = new DateTime();
                 $dt->setTimestamp($latest_update);
                 $update_time = $dt->format("g:iA");
                 $update_date = $dt->format("Y/m/d");
                 $thread->updateUpdateTime($update_time, $update_date, $latest_update);
                 $redirect_to .= $thread_id;
             }
             header("Location: " . $redirect_to);
             die;
         } else {
             // you are not the owner of the post, you don't have the permission to alter
             Utils::showNoPermissionPage();
             include VIEWS_PATH . "private-nav.php";
             include VIEWS_PATH . "thread/thread.php";
             die;
         }
     } else {
         // get request
         $thread->initWithId($thread_id);
         $post = $thread->getPostById($post_id);
     }
     $permission = $thread->getPermission();
     if (!self::checkingPermission($thread_id, $post_id, $permission) || !($_SESSION[KEY_SESSION][Account::KEY_ID] == $post->getAuthor()->getId())) {
         Utils::showNoPermissionPage();
         return;
     }
     $content = "delete.php";
     include VIEWS_PATH . "private-nav.php";
     include VIEWS_PATH . "thread/thread.php";
 }
開發者ID:plainbanana,項目名稱:eicforum,代碼行數:52,代碼來源:thread.php


注:本文中的Thread::updateUpdateTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。