Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2003
    Posts
    3

    Unanswered: 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?

  2. #2
    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

  3. #3
    Join Date
    Feb 2003
    Posts
    3
    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.

  4. #4
    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

  5. #5
    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.

  6. #6
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •