コード例 #1
0
ファイル: forum.thread.php プロジェクト: TheDoxMedia/pgs
 protected static function create($cat, $specifics, $user)
 {
     // Call DB Connector
     $callDB = new PGSdb();
     $callDB->connDB();
     $newThreadName = $specifics['title'];
     $newThreadPost = $specifics['content'];
     $newThreadCategory = $cat;
     $newThreadTime = time();
     $newThreadAuthor = $user['Username'];
     //Prepare
     $newThreadPrep = $callDB->db->prepare("INSERT INTO forum_threads(category, title, author, lastposter, timecreated, timelastpost) VALUES(:categoryN, :titleN, :authorN, :lastposterN, :timecreatedN, :timelastpostN)");
     //Execute
     $newThreadPrep->execute(array('categoryN' => $newThreadCategory, 'titleN' => $newThreadName, 'authorN' => $newThreadAuthor, 'lastposterN' => $newThreadAuthor, 'timecreatedN' => $newThreadTime, 'timelastpostN' => $newThreadTime));
     //Get the thread id
     $getNewThreadID = thread::get_by_title($newThreadName, $newThreadTime);
     $newThreadID = $getNewThreadID['id'];
     //Queue in the thread message into posts
     //Prepare
     $newPostPrep = $callDB->db->prepare("INSERT INTO forum_posts(category, thread, postorderid, author, post, timeposted) VALUES(:categoryN, :threadN, :postorderidN, :authorN, :postN, :timepostedN)");
     //Execute
     $postOrderID = '1';
     $newPostPrep->execute(array('categoryN' => $newThreadCategory, 'threadN' => $newThreadID, 'postorderidN' => $postOrderID, 'authorN' => $newThreadAuthor, 'postN' => $newThreadPost, 'timepostedN' => $newThreadTime));
     // //Incriment users post and thread count
     // $this->updateUserPostCount($newThreadAuthor);
     return array('createCategory' => $cat, 'threadCreated' => $getNewThreadID, 'postCreated' => $newPostPrep->rowCount());
 }