vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need help with SQL query to return latest threads but not from ignored users.... (https://vborg.vbsupport.ru/showthread.php?t=74925)

charlesk 01-23-2005 12:55 PM

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.

miz 01-23-2005 12:57 PM

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

and please use php/sql tags in codes postings

Dean C 01-23-2005 01:13 PM

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 :)

charlesk 01-23-2005 01:24 PM

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.)

sabret00the 01-23-2005 01:35 PM

can't you select distinct?

charlesk 01-23-2005 01:55 PM

distinct doesnt work because the post information is different.

c

BluPhoenix 01-24-2005 04:26 AM

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

charlesk 01-28-2005 12:41 AM

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.

charlesk 01-29-2005 10:28 PM

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.

Andreas 01-29-2005 10:44 PM

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]


All times are GMT. The time now is 11:13 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.01774 seconds
  • Memory Usage 1,724KB
  • 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
  • (3)bbcode_code_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