Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 05-19-2008, 12:51 AM
chrisjacob chrisjacob is offline
 
Join Date: May 2008
Location: Sydney
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I extract all posts from a thread

Need to extract all the posts allocated to a thread and store this information in an array.

I can use the following to fetch thread info for 1 thread:
PHP Code:

$threadinfo 
fetch_threadinfo($threadid); 
$threadinfo stores an array with the following details (and more):
threadid : 29
title : Extract this thread
firstpostid : 39
lastpostid : 43
lastpost : 1211157483 -- I don't know what this number is for?
forumid : 3
...

And I can use the following to fetch post info for 1 post:
PHP Code:
$postinfo fetch_postinfo($postid); 
$postinfo stores an array with the following details (and more):
postid : 41
threadid : 29
parentid : 40
username : test
userid : 2
title : 3rd post from Test User
dateline : 1211155226
pagetext : This is a 3rd post
...

Q1. The trouble I'm having is fetching ALL posts that belong to a thread.

Q2. Can I do this using vB Data Managers (is there an existing DM for this?) or do I need to query the database via the vBulletin DB Class (https://vborg.vbsupport.ru/showthrea...ht=fetch_field
)

Q3 - Heres my proposed solution. Please pick it to bits - security, speed, stupidity, etc..
Currently I'm thing of using Data Managers and looping through posts as follows:
1) fetch the thread_info 1st and find out it's LAST post ID and FIRST Post ID
2) fetch the post_info for the LAST post and save it's details to an array ($allposts)
3) use the LAST post's "parentid" to find the next post to look for.
4) repeat this process until the Post's "postid" == the Thread's "firstpostid"

--------------- Added [DATE]1211242198[/DATE] at [TIME]1211242198[/TIME] ---------------

This seems to work well:
PHP Code:
        chdir('/var/www/vhosts/example.net.au/subdomains/abc/httpdocs/forum');
        require_once(
'./global.php');

        
$tThreadId 29;
        
        echo 
"<h2>Thread Posts for Thread ID: $tThreadId</h2>";
        
$result_set $vbulletin->db->query_read("SELECT * FROM " TABLE_PREFIX "post WHERE threadid = $tThreadId");  
        while (
$result $vbulletin->db->fetch_array($result_set))
        {
            echo 
"<h3>Post ID: ".$result['postid']."</h3>";
            
reset($result);
            while (list(
$key$value) = each ($result))
            {
                echo 
"$key : $value <br />";
            }
        }
        
$vbulletin->db->free_result($result_set); 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:48 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02979 seconds
  • Memory Usage 2,162KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete