vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Forumhome attachment query (https://vborg.vbsupport.ru/showthread.php?t=192749)

squishi 10-05-2008 10:39 AM

Forumhome attachment query
 
Hello,

I want to do a query in a plugin on the forumhome that is rather difficult for me to do.

I want to query the latest submitted attachment of 4 different forums (one attachment for each forum).

I had a look at the attachment database table, but there is of course no info in which forum the attachment was posted.

So the query would probably consist of several joins (qeurying the latest thread of a forum and then querying the latest attachment of that forum).

Can anybody help, please? :o

squishi 10-22-2008 02:12 PM

How do I query the latest attachment in a certain forum, please?

squishi 11-30-2008 09:11 AM

Bump. I'm still looking for a way to do this.

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

I guess the way to do this is find out the latest thread in a forum and then query the first attachment in this thread.
Should not be impossible. The forumhome shows info about the latest thread already...

bartek24m 01-23-2011 03:19 PM

I'm also looking for a way to do this.

kh99 01-23-2011 03:59 PM

Maybe something like this:

Code:

"SELECT attachmentid FROM " . TABLE_PREFIX . "attachment AS attachment
      LEFT JOIN " . TABLE_PREFIX . "post AS post ON ( post.postid = attachment.postid )
      LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON ( thread.threadid = post.threadid )
    WHERE thread.forumid IN ( 1, 2, 3 )
    ORDER BY attachment.dateline DESC"


which finds attachment ids from forums 1, 2, or 3, newest ones first. I'm really just an SQL beginner so I don't know how you would do what the OP wants in one query. I suppose you could query all the attachments and read them until you find one from each forum, but i don't know how you'd do a query to return exactly one from each forum.


All times are GMT. The time now is 03:24 PM.

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.01041 seconds
  • Memory Usage 1,716KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete