vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How can i get the first post only? (https://vborg.vbsupport.ru/showthread.php?t=184174)

vietdjclub 07-02-2008 12:54 PM

How can i get the first post only?
 
somebody know the way to get only first post ,

ex: i have the topic with 20 reply on it.

xxx (owner posted)
x1
x2
x3
...
x20

now i want to write a query to get only xxx (owner posted)
how can i do it
Thank for reading my question

Opserty 07-02-2008 02:32 PM

[SQL]
SELECT *
FROM thread
LEFT JOIN post ON ( post.postid = thread.firstpostid )
WHERE thread.threadid = AAA
[/SQL]
(Where AAA is the thread id)

vietdjclub 07-03-2008 12:06 AM

thank Opserty

Dismounted 07-03-2008 05:36 AM

You may want to just grab the post's info, instead of including thread data, to save on memory.
[sql]SELECT p.*
FROM thread AS t
LEFT JOIN post AS p ON (p.postid = t.firstpostid)
WHERE t.threadid = X[/sql]

Paul M 07-03-2008 01:55 PM

I hate it when people use single letters in sql. :)

Dismounted 07-03-2008 02:14 PM

[sql]SELECT post.*
FROM thread AS thread
LEFT JOIN post AS post ON (post.postid = thread.firstpostid)
WHERE thread.threadid = X[/sql]
Happy now, Paul? :p

Opserty 07-03-2008 03:53 PM

You don't need the "AS thread" or "AS post" if they are the same as the table names no? :p

Blindspot 07-03-2008 10:35 PM

even easier
PHP Code:

$postinfo fetch_postinfo($thread['firstpostid']); 

and if you dont have $thread

PHP Code:

$threadinfofetch_postinfo($threadid);
$postinfo fetch_postinfo($threadinfo['firstpostid']); 


vietdjclub 07-03-2008 11:31 PM

wow it's great for coder. big thank all

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

thank for first question. now i got trouble with query

my query:
Code:

$x = $vbulletin->db->query_read("
                        SELECT * FROM " . TABLE_PREFIX . "thread as t
                        INNER JOIN " . TABLE_PREFIX . "post as p ON (t.threadid = p.threadid)                       
                        WHERE forumid IN(xx) ORDER BY p.post_thanks_amount DESC LIMIT 0 , 5");

while ($xxx = $vbulletin->db->fetch_array($x))
                {                               
                        $mymessage = $xxx['threadid'];                                               
                        $threaddm->do_set('pagetext', $mymessage);
                }

more code....

the thread auto create perfectly with all infomation but 'pagetext' can not get anything from my query, it's empty.

i want to ask who can help me: how can i get 5 threadid and put it on 'pagetext'

it's mean 1 new thread with 5 threadid (i got from above query) on its

best regard,

vietdjclub 07-04-2008 03:19 AM

please help me with code

my query:
Code:

$x = $vbulletin->db->query_read("
                        SELECT * FROM " . TABLE_PREFIX . "thread as t
                        INNER JOIN " . TABLE_PREFIX . "post as p ON (t.threadid = p.threadid)                       
                        WHERE forumid IN(xx) ORDER BY p.post_thanks_amount DESC LIMIT 0 , 5");

while ($xxx = $vbulletin->db->fetch_array($x))
                {                               
                        $mymessage = $xxx['threadid'];                                               
                        $threaddm->do_set('pagetext', $mymessage);
                }

              $threaddm->do_set('forumid', $to_forum_1);       
                $threaddm->do_set('postuserid', $postuserid);
                $threaddm->do_set('userid', $postuserid);
                $threaddm->do_set('username', $postusername);               
                    $threaddm->do_set('title', $title);
                $threaddm->do_set('allowsmilie', $allowsmilie);
                $threaddm->do_set('visible', $visible);
                $tid = $threaddm->save();

the thread auto create perfectly with all infomation but 'pagetext' can not get anything from my query, it's empty.

i want to ask who can help me: how can i get 5 threadid and put it on 'pagetext'

it's mean 1 new thread with 5 threadid (i got from above query) on its

best regard,


All times are GMT. The time now is 06:09 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.01500 seconds
  • Memory Usage 1,734KB
  • 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
  • (2)bbcode_php_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