vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   problem with variables in plugin (https://vborg.vbsupport.ru/showthread.php?t=101445)

Schluml 11-24-2005 06:19 AM

problem with variables in plugin
 
hi,

i've got a plugin with a query which is gettin the threads in different forums for each user.

My problem is, i save the query result in a variable and want to print it in the postbit, but the variable seems to be empty in postbit. As hook i'm using
"showthread_postbit_create"

query code:
PHP Code:

$tresult $vbulletin->db->query_first("SELECT COUNT(*) AS anzahl FROM "TABLE_PREFIX ."thread WHERE forumid IN (1,4,8) AND postuserid=".$post['userid'].""); 

in postbit i'm using:

PHP Code:

$result[anzahl

but, nothing happens...

the qery seems to be ok, i tested it.

so, whats the problem?

P.S. my english isnt perfect, hope u understand me :)

calorie 11-24-2005 06:27 AM

Try setting $tresult_anzahl = $tresult['anzahl']; and then use $tresult_anzahl in postbit.

Schluml 11-24-2005 06:41 AM

hi, thx but still the same problem... :(

calorie 11-24-2005 06:58 AM

Try setting $post['anzahl'] = $tresult['anzahl']; and then use $post[anzahl] in postbit.

tnguy3n 11-24-2005 07:00 AM

you declared the variable to be $tresult, so to print your result in postbit, you should put $tresult[anzahl]

merk 11-24-2005 07:03 AM

showthread_postbit_create is the wrong hook.

Use postbit_display_complete.

Marco van Herwaarden 11-24-2005 07:09 AM

$tresult != $result

Use $tresult[anzahl] in your postbit.
If it still don't show, add the following line to the top of your plugin:
PHP Code:

global $tresult

PS A much better/nicer way of doing this would be:
PHP Code:

$tresult $vbulletin->db->query_first("SELECT COUNT(*) AS anzahl FROM "TABLE_PREFIX ."thread WHERE forumid IN (1,4,8) AND postuserid=".$post['userid']."");  
$post['anzahl'] = $tresult['anzahl']; 

This is because $post is the array that is used everywhere else to store the values of a single post.

Please also note that this should be optimized to avoid performance issues. Your plugin (and the query inside) will be executed for each post on a page, also if the same member has posted more then once on the same page. It would be better to retrieve the values of each user that has posted only once.

calorie 11-24-2005 07:09 AM

ignore... being dumb or tired or both

merk 11-24-2005 10:40 AM

$this->registry->db

calorie 11-24-2005 11:00 AM

Thanks merk, didn't think of that, duh on me.


All times are GMT. The time now is 01:46 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.01107 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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