vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   forumhome: PM Queries optimization! (https://vborg.vbsupport.ru/showthread.php?t=44131)

N9ne 09-30-2002 06:45 PM

forumhome: PM Queries optimization!
 
I've seen people post about combining the "unread PMs, total PMs, new PMs" queries, into just one from three! How can this be achieved?! I would love to know because I need to combine them ;)

Xenon 09-30-2002 06:47 PM

this are the codelines instead the original 3 queries:
PHP Code:

  $allpm=$DB_site->query_first("SELECT COUNT(*) AS messages,
                                SUM(IF(dateline>
$bbuserinfo[lastvisit] AND folderid=0,1,0)) AS newpm,
                                SUM(IF(messageread=0 AND folderid=0,1,0)) AS unreadpm
                                FROM privatemessage WHERE userid=
$bbuserinfo[userid] $ignoreusers");

  
$newpm['messages']=$allpm['newpm'];
  
$unreadpm['messages']=$allpm['unreadpm']; 


Erwin 09-30-2002 06:55 PM

I've always wondered why the vB team has never made this a standard thing in the latest versions of vB.

Xenon 09-30-2002 06:56 PM

good question...

i think they just wanted to fix all bugs, but leave their head free for working on vb3 ;)
if they had also optimizations for vb2 in the head they'll get confused *g*

N9ne 09-30-2002 07:21 PM

What are the variables to put in forumhome_pmloggedin template with that code? I have Total PMs working, but not unread and new PMs since your last visit...

Erwin 09-30-2002 07:26 PM

You can't decrease queries in templates.

You need to edit the PHP files.

Replace the PM query lines in index.php with the code that Xenon put up.

Xenon 09-30-2002 07:26 PM

you don't have to change anything in your templates, it is just a code replace

N9ne 09-30-2002 07:31 PM

No, I understand that...however it seems the variable to place in forumhome_pmloggedin has changed, as no number shows up. I think it may be:

$allpm['newpm']

And:

$allpm['unreadpm']

now?

Xenon 09-30-2002 07:38 PM

this is the original part:
PHP Code:

  $allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
  
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
  
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers"); 

as you can see if you have replaced it with exact the part i post above no variablenames have changed

N9ne 10-01-2002 07:43 PM

Ok I figured out what was confusing me! I had no unread messages, and no new PMs so it didn't show 0, it showed nothing at all...is there a way to make it say 0 if you don't have any, instead of not showing anything at all?


All times are GMT. The time now is 10:06 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.01154 seconds
  • Memory Usage 1,734KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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