vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Fetch post? (https://vborg.vbsupport.ru/showthread.php?t=214942)

MarkFoster 05-30-2009 10:05 PM

Fetch post?
 
Is there anyways, whatsoever. That I will be able to fetch a post from the forums and put it on a custom page?

Like a code for this specific message?

Lynne 05-30-2009 10:15 PM

Sure, with a query. If you have the postid, just make a query to the database for the message text. Just look up the query in showpost.php (the page for grabbing a single post, like you mentioned)

MarkFoster 05-30-2009 10:29 PM

Quote:

Originally Posted by Lynne (Post 1820322)
Sure, with a query. If you have the postid, just make a query to the database for the message text. Just look up the query in showpost.php (the page for grabbing a single post, like you mentioned)

If I'm not wrong you mean the vBulletin CP function called "Execute SQL Query", right?
However I'm not good at this. Or knowing. Are you telling me I have to make a code via looking at the "showpost.php" and put it through the SQL thing and then put it in the template?

I'd rather get a little more help here, please :)

Lynne 05-30-2009 10:42 PM

Yes, I am saying you will have to do the "SQL thing" in order to grab the post. I'm suggesting you look in the showpost.php page because they used the same query there that you will need to use.

MarkFoster 05-30-2009 10:51 PM

Quote:

Originally Posted by Lynne (Post 1820333)
Yes, I am saying you will have to do the "SQL thing" in order to grab the post. I'm suggesting you look in the showpost.php page because they used the same query there that you will need to use.

I looked at the showpost.php. Three times. But I'm not sure what I should take. I'm sorr.y I'm just not any good at this.

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

It's really hard for me to figure out.
Could it possibly be related to this?
Code:

if ($postbit_obj->cachable)
{
        /*insert query*/
        $db->shutdown_query("
                REPLACE INTO " . TABLE_PREFIX . "postparsed (postid, dateline, hasimages, pagetext_html, styleid, languageid)
                VALUES (
                        $post[postid], " .
                        intval($threadinfo['lastpost']) . ", " .
                        intval($postbit_obj->post_cache['has_images']) . ", '" .
                        $db->escape_string($postbit_obj->post_cache['text']) . "', " .
                        intval(STYLEID) . ", " .
                        intval(LANGUAGEID) . "
                        )
        ");
}


Lynne 05-31-2009 01:08 AM

I hate to tell you, but it's the big huge one that starts on line 124. That is the basic query that gets *everything* needed to spit out the post - the post itself, the userinfo regarding the person who posted it, the sig, the avatar, etc.... You never said how much of the post you want - just the message text? If so, you can get rid of anything there regarding userinfo/avatar/signature/spamlog/userfield/editlog/sigparsed/usertextfield.

Dismounted 05-31-2009 03:53 AM

[sql]SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = X[/sql]
That will fetch one specific post and associated user data. Note that the post will not have been parsed for BB code. If you have the knowledge/time, you may want to investigate fetching the cached post if available.

MarkFoster 05-31-2009 04:25 AM

Quote:

Originally Posted by Dismounted (Post 1820447)
[sql]SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = X[/sql]
That will fetch one specific post and associated user data. Note that the post will not have been parsed for BB code. If you have the knowledge/time, you may want to investigate fetching the cached post if available.

Okay. So lets say I put this in my SQL:
Code:

SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = 12066

Then what's the code I have to use to make it appear on the page?

Dismounted 05-31-2009 06:18 AM

Providing you use query_first() to perform the query, all the data is inside the variable you assign it to. Open up the post table in phpMyAdmin (or similar) and see the structure.

MarkFoster 05-31-2009 06:32 AM

Quote:

Originally Posted by Dismounted (Post 1820502)
Providing you use query_first() to perform the query, all the data is inside the variable you assign it to. Open up the post table in phpMyAdmin (or similar) and see the structure.

I'm not good at this. I tried to look for something but I couldn't. Anymore help with be appreciated.


All times are GMT. The time now is 07:08 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.01089 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete