示例#1
0
    /**
     * Hard delete the stuff for this topic
     */
    public function delete()
    {
        $post = new titania_post();
        $post->topic = $this;
        $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . '
			WHERE topic_id = ' . (int) $this->topic_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $post->__set_array($row);
            $post->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Remove any subscriptions to this topic
        $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
			WHERE watch_object_type = ' . TITANIA_TOPIC . '
				AND watch_object_id = ' . $this->topic_id;
        phpbb::$db->sql_query($sql);
        // Remove any tracking for this topic
        $this->tracking->clear_item(TITANIA_TOPIC, $this->topic_id);
        // Delete the now empty topic
        $sql = 'DELETE FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE topic_id = ' . $this->topic_id;
        phpbb::$db->sql_query($sql);
    }