View Single Post
  #15  
Old 12-11-2009, 11:54 AM
vaskies vaskies is offline
 
Join Date: Dec 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I thought I would remedy the situation by modifying the plugin's code. I tried a zillion things, but only two of them are really worth mentioning. Here's the original snippet:
Code:
$forumdevel1 = $vbulletin->options['lastxforumid1'];
$forumnamedevel1 = $vbulletin->options['forumnamedevel1'];
$limitdevel1 = $vbulletin->options['lastxlimit1'];
if ($vbulletin->options['endislastx'])
if ($vbulletin->options['endislastx1'])
$lastxdevels1 = $db->query_read("
     SELECT threadid, title, postusername, replycount, lastposter, lastpost, views, attach
     FROM " . TABLE_PREFIX . "thread
     WHERE forumid IN ($forumdevel1)
     AND visible = 1
     order by $ord DESC
     LIMIT $limitdevel1
     ");


while ($lastxdevel1 = $db->fetch_array($lastxdevels1))
{

   if(strlen($lastxdevel1['title']) > $vbulletin->options['lastxmax'])
    {
        $lastxdevel1['title'] = substr($lastxdevel1['title'], 0, $vbulletin->options['lastxmax']) . ' ...';
    }

	    $agdate1 = vbdate($vbulletin->options['dateformat'], $lastxdevel1[lastpost], true);  
    $agtime1 = vbdate($vbulletin->options['timeformat'], $lastxdevel1[lastpost]); 

	
$lastxdevelt1.="<div class='smallfont'><font size='2'><a onmouseover=\"Tip('<b>Title:</b> $lastxdevel1[title]<br/><b>User:</b> $lastxdevel1[lastposter]<br /><b>Last Post:</b>$agdate1<br/><b>Preview:</b>will go here... <br/>')\" onmouseout=\"UnTip()\" href='showthread.php?t=$lastxdevel1[threadid]'>$lastxdevel1[title]</a></font></div>";
}
And here's what I added:
Code:
$forumdevel1 = $vbulletin->options['lastxforumid1'];
$forumnamedevel1 = $vbulletin->options['forumnamedevel1'];
$limitdevel1 = $vbulletin->options['lastxlimit1'];
if ($vbulletin->options['endislastx'])
if ($vbulletin->options['endislastx1'])
$lastxdevels1 = $db->query_read("
     SELECT threadid, title, postusername, replycount, lastposter, lastpost, views, attach
     FROM " . TABLE_PREFIX . "thread
     WHERE forumid IN ($forumdevel1)
     AND visible = 1
     order by $ord DESC
     LIMIT $limitdevel1
     ");


$threadPreviewThings = $db->query_read("
     SELECT pagetext
     FROM " . TABLE_PREFIX . "post
     WHERE threadid IN ($forumdevel1)
     AND visible = 1
     LIMIT $limitdevel1
     ");

$threadPreviewThing = $db->fetch_array($threadPreviewThings);

while ($lastxdevel1 = $db->fetch_array($lastxdevels1))
{

   if(strlen($lastxdevel1['title']) > $vbulletin->options['lastxmax'])
    {
        $lastxdevel1['title'] = substr($lastxdevel1['title'], 0, $vbulletin->options['lastxmax']) . ' ...';
    }
	
	    $agdate1 = vbdate($vbulletin->options['dateformat'], $lastxdevel1[lastpost], true);  
    $agtime1 = vbdate($vbulletin->options['timeformat'], $lastxdevel1[lastpost]); 

	
$lastxdevelt1.="<div class='smallfont'><font size='2'><a onmouseover=\"Tip('<b>Title:</b> $lastxdevel1[title]<br/><b>User:</b> $lastxdevel1[lastposter]<br /><b>Last Post:</b>$agdate1<br/><b>Preview:</b>$threadPreviewThing[pagetext] <br/>')\" onmouseout=\"UnTip()\" href='showthread.php?t=$lastxdevel1[threadid]'>$lastxdevel1[title]</a></font></div>";
}

Which caused the mouseover to not show up at all (i.e. breaking it). I obviously am approaching this from the wrong angle. So I did a google search of how to read from two tables at once and many sites said it was impossible. But as you see in the code, that variable $lastxdlevels1 has to be assigned to a query_read. But the 4 values I need are in two different tables, yeah? This is problematic.

So I decided, why not try assigning what table I'm using into an array of two different values.

Code:
$dbTables = array(thread, post);
$forumdevel1 = $vbulletin->options['lastxforumid1'];
$forumnamedevel1 = $vbulletin->options['forumnamedevel1'];
$limitdevel1 = $vbulletin->options['lastxlimit1'];
if ($vbulletin->options['endislastx'])
if ($vbulletin->options['endislastx1'])
$lastxdevels1 = $db->query_read("
     SELECT threadid, title, postusername, replycount, lastposter, lastpost, views, attach, pagetext
     FROM " . TABLE_PREFIX . "{$dbTables}
     WHERE forumid IN ($forumdevel1)
     AND visible = 1
     order by $ord DESC
     LIMIT $limitdevel1
     ");

while ($lastxdevel1 = $db->fetch_array($lastxdevels1))
{

   if(strlen($lastxdevel1['title']) > $vbulletin->options['lastxmax'])
    {
        $lastxdevel1['title'] = substr($lastxdevel1['title'], 0, $vbulletin->options['lastxmax']) . ' ...';
    }
	
	    $agdate1 = vbdate($vbulletin->options['dateformat'], $lastxdevel1[lastpost], true);  
    $agtime1 = vbdate($vbulletin->options['timeformat'], $lastxdevel1[lastpost]); 

$lastxdevelt1.="<div class='smallfont'><font size='2'><a onmouseover=\"Tip('<b>Title:</b> $lastxdevel1[title]<br/><b>User:</b> $lastxdevel1[lastposter]<br /><b>Last Post:</b>$agdate1<br/><b>Preview:</b>$lastxdevel1[pagetext] <br/>')\" onmouseout=\"UnTip()\" href='showthread.php?t=$lastxdevel1[threadid]'>$lastxdevel1[title]</a></font></div>";
}
Which turned out this error:

MySQL Error : Table 'vb3.array' doesn't exist
Error Number : 1146


Hindsight that was a stupid idea, since $dbTables simply outputs "Array". In summation, I tried splitting the code up into two separate query reads with no luck. And then I tried consolidating them via an array which probably never would have worked anyway, because even if I could display the values, they would not translate with the SQL syntax!

If I'm ever going to figure this out, one thing is for sure: I'm going to need to improve my knowledge on vbulletin's database structure as well as my understanding of SQL syntax. Which is exactly what I'm going to attempt today. I just learned I could view the database tables in phpMyAdmin which has been expontentially helpful...

And by the way, you were right! Taking out the single quotes worked. I still need the thread preview, though, so using the external data provider thing, as you said, wouldn't be the best approach.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01223 seconds
  • Memory Usage 1,792KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete