If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > vBulletin 2.2.6 question (exclude forums from query)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-03, 11:49
Iken Iken is offline
Registered User
 
Join Date: Feb 2003
Posts: 3
vBulletin 2.2.6 question (exclude forums from query)

Hi all,

I want to change the following code in index.php:

$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");

I want to exclude two forums from these queries, how?
Thank you!


Someone suggested this ->
Yes, the forumid 1/2 are the forumid's that you don't want to be included, and your queries would look like this:

$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit] AND forumid!=forumid1 AND forumid!=forumid2'");

$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit] AND forumid!=forumid1 AND forumid!=forumid2'");

But this didn't work. Any suggestions?
Reply With Quote
  #2 (permalink)  
Old 03-19-03, 12:42
MattR MattR is offline
Registered User
 
Join Date: Mar 2001
Location: Lexington, KY
Posts: 606
AND forumid NOT IN ( 123, 456 )

of course change 123 and 456 to be your actual forum IDs that you wish to omit.
__________________
Thanks,

Matt
Reply With Quote
  #3 (permalink)  
Old 03-19-03, 19:48
Iken Iken is offline
Registered User
 
Join Date: Feb 2003
Posts: 3
Quote:
Originally posted by MattR
AND forumid NOT IN ( 123, 456 )

of course change 123 and 456 to be your actual forum IDs that you wish to omit.
Thanks for your reply but this doesn't work.
Reply With Quote
  #4 (permalink)  
Old 03-19-03, 21:00
MattR MattR is offline
Registered User
 
Join Date: Mar 2001
Location: Lexington, KY
Posts: 606
It should. What do you mean by 'doesn't work'. Show the exact query you are entering.
__________________
Thanks,

Matt
Reply With Quote
  #5 (permalink)  
Old 03-20-03, 05:08
Iken Iken is offline
Registered User
 
Join Date: Feb 2003
Posts: 3
This are the two queries:

$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit] AND forumid NOT IN ( 31, 33, 37 ) '");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit] AND forumid NOT IN ( 31, 33, 37 ) ' ");

They work but they not exclude the forums I want.
Reply With Quote
  #6 (permalink)  
Old 04-04-03, 12:12
MattR MattR is offline
Registered User
 
Join Date: Mar 2001
Location: Lexington, KY
Posts: 606
I don't think post has the forumid table in it.

That means you will have to JOIN to the thread table which can get very expensive. Why not look at the forum table? There is a postcount column on there.
__________________
Thanks,

Matt
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On