Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #31  
Old 12-05-2014, 08:37 PM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think we're good for now. If I run my select at showthread_start and simply save everything to $countries, will that be accessible by my plugin in the postbit?

After testing, it seems no matter where I put the $countries selection it does not execute. Do sql executions not work in plugins?
Reply With Quote
  #32  
Old 12-05-2014, 09:36 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I do queries all the time with them. As long as your query comes after the file has required global.php you'll have a database connection. Do you have a function that needs $countries? Use "global $countries;" in it.

If your plugin is inside an existing vbulletin function (and I suspect it is) you have to get $countries inside the function. You could use the line

$vbulletin->countries = $countries;

after your query and then refer to it that way in your plugin, or if that doesn't work refer to it as

$this->registry->countries

in your plugin.
Reply With Quote
  #33  
Old 12-05-2014, 10:05 PM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, here are my plugins, which are not working (or at least no flags are showing up):
showthread_start
PHP Code:
$sql "SELECT * FROM " TABLE_PREFIX "countrycodes";
        
$result $db->query_read_slave($sql);
        
        while (
$c mysql_fetch_array($result) {
            
$countries[$c[0]] = $c[1];
        }

$vbulletin->countries $countries
postbit_display_complete
PHP Code:
$ccode array_search($post['field58'], $vbulletin->countries);

    if (
$ccode != null) {
        
$imgoutput "<img src='images/flags/$ccode.png' class='inlineimg' alt='$country' />&nbsp;&nbsp;";
    }

$templatevalues['ccimg'] = "$imgoutput";
vB_Template::preRegister('postbit_legacy'$templatevalues); 
Note: When I attempt to var_dump the $countries array after it's created, I get null, so the query itself is not being executed, even though you'd think that this was LONG after the global.php had been included...
Reply With Quote
  #34  
Old 12-06-2014, 12:34 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not very good with sql. What are your actual field names? I would try using those instead of 0 and 1.

And try

$result = $vbulletin->db->query_read_slave($sql);

$db doesn't always work but $vbulletin->db should
Reply With Quote
  #35  
Old 12-06-2014, 12:35 AM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Update: When I switched from using the $vbulletin->db commands to just using mysql_ commands everything worked. ^^
Reply With Quote
  #36  
Old 12-06-2014, 03:00 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's strange. When you require global.php it requires various other files such as includes/core.php which has all the database stuff.

Glad you got it working.
Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:15 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.11304 seconds
  • Memory Usage 2,218KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete