The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Any way to optimize my code or cut down on queries?
I took this MOD:
https://vborg.vbsupport.ru/showthread.php?t=97403 And turned it into this: Attachment 51318 I did it without any real prior knowledge of php or mySQL so I'm sure my code is very inefficient. I pieced it together from what was already in the MOD and got the rest from trial & error. Here's the plugin code. Any feedback is appreciated, thank you. Original Code: Code:
// ### LATEST NEWS BY TANTAWI ############################################ $latesta = $db->query_first('SELECT title,threadid,views,replycount FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 28 ORDER BY dateline DESC LIMIT 1'); $lns_show = "<a href=\"showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$latesta[threadid]\">$latesta[title]</a>"; Code:
// ### LATEST NEWS BY TANTAWI ############################################ $latesta = $db->query_first('SELECT title,threadid,views,replycount,postusername,dateline FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 28 ORDER BY dateline DESC LIMIT 0 , 1'); $lns_show = "<a href=\"showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$latesta[threadid]\">$latesta[title]</a>"; $lnsurl_show = "<a href=\"showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$latesta[threadid]\">[Read More]</a>"; $lns2_show = "<b>Replies:</b> $latesta[replycount] <b>Views:</b> $latesta[views]"; $lns3_show = "<a href=\"http://pokerealm.net/forums/member.php?do=getinfo&username=$latesta[postusername]\">$latesta[postusername]</a>"; $latgetpost = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $latesta[threadid]. ' ORDER BY dateline ASC LIMIT 0 , 1'); $lat_show = "$latgetpost[pagetext]"; $postchars = 250; $cuttedpost = substr($latgetpost[pagetext],$postchars,1); if($cuttedpost !=" "){ while($cuttedpost !=" "){ $i=1; $postchars=$postchars+$i; $cuttedpost = substr($latgetpost[pagetext],$postchars,1); } } $cuttedpost = substr($latgetpost[pagetext],0,$postchars); $authshow = vbdate($vbulletin->options['dateformat'], $latesta['dateline']); $authshow2 = vbdate($vbulletin->options['timeformat'], $latesta['dateline']); $amtans = $db->query_first('SELECT threadcount FROM ' . TABLE_PREFIX . 'forum WHERE 1 AND forumid = 28 ORDER BY forumid DESC LIMIT 0 , 1'); $amt_show = "$amtans[threadcount]"; |
#2
|
|||
|
|||
Bump.
|
#3
|
||||
|
||||
In your queries, you can remove the bold bits as per the example below;
Code:
SELECT threadcount FROM ' . TABLE_PREFIX . 'forum WHERE 1 AND forumid = 28 ORDER BY forumid DESC LIMIT 0 , 1 |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|