Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2005, 12:55 PM
charlesk charlesk is offline
 
Join Date: Nov 2004
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help with SQL query to return latest threads but not from ignored users....

Hey all,

I am attempting to modify the excellent "most recent threads" hack so that threads that were just responded to by someone on the ignore list are not shown. Before changing the code I am trying to figure out what SQL I need, so I have been testing with direct queries.

The closest I have gotten is this:

select post.*, thread.* from post,thread where post.userid not in ('275','135','1') AND post.threadid = thread.threadid order by post.dateline desc

In this case the "('275','135','1')" are the three sample user IDs I am "ignoring".

This works.. but the problem is that because it orders by posts, if there is more than one recent response to the same thread, the thread appears twice. I can't figure out how to get it to show only one thread no matter how many recent posts it has.

Can anyone help?

Thanks.
Reply With Quote
  #2  
Old 01-23-2005, 12:57 PM
miz miz is offline
 
Join Date: Mar 2003
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so you tring to get lastest threads but not from ignored users
am i right ?

and please use php/sql tags in codes postings
Reply With Quote
  #3  
Old 01-23-2005, 01:13 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Rightio, I'm leaving for a couple of days now. I'll give you a hand when I get back providing no-one has helped you before then
Reply With Quote
  #4  
Old 01-23-2005, 01:24 PM
charlesk charlesk is offline
 
Join Date: Nov 2004
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Correct miz. Sorry about not using the right tags.

Thanks Dean, hoping I can find some help sooner but if not, that will be nice.

I realized I can "kludge" around this by keeping track of the threads already seen in the loop that processes the results, but that's ugly.)
Reply With Quote
  #5  
Old 01-23-2005, 01:35 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can't you select distinct?
Reply With Quote
  #6  
Old 01-23-2005, 01:55 PM
charlesk charlesk is offline
 
Join Date: Nov 2004
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

distinct doesnt work because the post information is different.

c
Reply With Quote
  #7  
Old 01-24-2005, 04:26 AM
BluPhoenix BluPhoenix is offline
 
Join Date: Nov 2004
Location: Wirral Peninsula
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

add this before the latest threads code:

Code:
// ## USERS IGNORE ##
if (trim($bbuserinfo['ignorelist'])) {
	$ignoredposters = 'AND thread.postuserid NOT IN ('.str_replace(' ', ',', $bbuserinfo['ignorelist']).')';
}
and then in the latest threads code, add:
Code:
$ignoredposters
just before:
Code:
ORDER BY lastpost
Reply With Quote
  #8  
Old 01-28-2005, 12:41 AM
charlesk charlesk is offline
 
Join Date: Nov 2004
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. I found a kludgy solution already but that looks much more elegant. I need to take a look and see if I can adapt it tomorrow.
Reply With Quote
  #9  
Old 01-29-2005, 10:28 PM
charlesk charlesk is offline
 
Join Date: Nov 2004
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just checked this again, it doesn't do what I need because it ignores whole threads based on the thread starter. I need it to ignore on a post-by-post basis. Thanks anyway though.
Reply With Quote
  #10  
Old 01-29-2005, 10:44 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What about this:

[sql]select post.*, thread.* from post,thread where post.userid not in ('275','135','1') AND post.threadid = thread.threadid group by thread.threadid order by post.dateline desc[/sql]
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 10:55 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.02432 seconds
  • Memory Usage 2,242KB
  • 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_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete