vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Query: show img attachment of every first post. (https://vborg.vbsupport.ru/showthread.php?t=214767)

Bernd 05-28-2009 05:38 PM

Query: show img attachment of every first post.
 
I have hardly worked with queries and I am trying to adjust a mod to show the first attachment of the first post of a specific forum.

Code:

$query_attachments = $vbulletin->db->query_read("
 SELECT thread.threadid, thread.firstpostid, thread.forumid, attachment.extension, attachment.postid, attachment.attachmentid
  FROM " . TABLE_PREFIX . "attachment
  INNER JOIN " . TABLE_PREFIX . "thread
  ON thread.firstpostid=attachment.postid
  WHERE (attachment.extension = 'jpg' OR attachment.extension = 'gif' OR attachment.extension = 'png') AND thread.forumid=6 AND dateline < " . TIME() ."
  ORDER BY dateline DESC LIMIT 5");

The basic idea is the following.
-thread.threadid can be used to link to a specific post using a hyperlink.
-thread.firstpostid has to match attachment.postid. Hopefully, this will return the threads with attachments.
-using the where clause, i want to restrict the returns to forum ID 6 only.

I have only tried simple queries in the past (first use of inner join) and I am wondering if the general idea for this query is sound. Any help or hints is appreciated.

Bernd 05-29-2009 07:16 PM

nobody?

kalisekj 05-31-2009 12:17 PM

Good Luck Bernd , I am also trying to show first attached image as my post icon and getting no replies or ideas even though this would truly expand VB to multiple new markets if it can do this.

Markets that could benefit from this:
Adult Sites
Fan Based Sites
Merchants selling Products
Movie Web Sites
Photo or Image Sites

Lynne 05-31-2009 04:33 PM

Don't you want to put something in there to grab it just for a specific threadid? AT what point are you running this query? And what is the expected result here?

Bernd 06-23-2009 10:20 AM

Quote:

Originally Posted by Lynne (Post 1820763)
Don't you want to put something in there to grab it just for a specific threadid? AT what point are you running this query? And what is the expected result here?

Sorry for the late reply, had tons of work to do.
Basically, what I am trying to create is a cmps module that displays the first image of every thread in a specific forum (e.g. latest 5 results) . The query will be running on every frontpage request, as it will be displaying the latest resources available in a specific forum (basically threads with binaries and image attachments).

Once fully working, I will post the modifications in the mod thread so that everybody will benefit from it.


All times are GMT. The time now is 11:05 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.02724 seconds
  • Memory Usage 1,718KB
  • 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)bbcode_quote_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