vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Running a query from plugin ? using default function ? (https://vborg.vbsupport.ru/showthread.php?t=232183)

Vaupell 01-04-2010 09:39 PM

Running a query from plugin ? using default function ?
 
Is it nessesary to assign a function to simply read some data from db..

Want a plugin to read

Tablename
colum1 |colum2|colum3
------------------------------
data1 | data2 | data 3

and so on.. well you know a table..

But using a query as i would when writing a .php file for vbulletin dont work so well
with plugins.. :(

normal :
Code:

$linkstat=$db->query_first("SELECT * FROM " . TABLE_PREFIX . "Tablename WHERE Colum1='1'");
$data1 = htmlspecialchars_uni($linkstat['data1']);
$data2 = htmlspecialchars_uni($linkstat['data2']);
$data3 = htmlspecialchars_uni($linkstat['data3']);

 $templater = vB_Template::create('some_template');
 $templater->register('data1', $data1);
 $templater->register('data2', $data2);
 $templater->register('data3', $data3);

 print_output($templater->render());

Howewer that just gives some
Fatal error: Call to a member function query_first() on a non-object in C:\xampp\xampp\htdocs\emod\includes\class_bootstra p.php(392) : eval()'d code on line 63

Which i just suppect is becourse the query_first should be something else .

but what. tryed looking at other plugins both from vb and from others
just cant figure them out..

help please.

consolegaming 01-04-2010 09:52 PM

It's the $db causing the issue. I had the same problem. $db doesn't seem to be defined any more.

$vbulletin->db->query_first()

That should work. Though the quickest change to make it work would just be to add $db = $vbulletin->db; at the start of the plugin.

ragtek 01-04-2010 10:03 PM

You can also use vB::$vbulletin->db->

They wrote in an blogcomment that $vbulletin->db also will not work, after they finish all the refactoring

Vaupell 01-04-2010 10:11 PM

how about that...

Lol well i can get $vbulletin->db->query_first working

but vB::$vbulletin.... dont..

i belive its missing something as in vB_?????::$vbulletin
ie : vB_Template::create

ragtek 01-04-2010 10:17 PM

Which hook are you using?

Vaupell 01-04-2010 10:26 PM

hook to "process_templates_complete"

any experience using ?

While ($row = $vbulletin->db->fetch_array($data))
{

worried about that ->db->

ragtek 01-04-2010 10:35 PM

It's working fine for me.

PHP Code:

$a vB::$db->query_first(...); 


consolegaming 01-04-2010 10:36 PM

Also concerning your worry about using ->db-> why not do $db = $vbulletin->db; at the start of the plugin? May not be the neatest solution but it would work. And then you can use $db as you used to.


All times are GMT. The time now is 10:24 PM.

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.01121 seconds
  • Memory Usage 1,723KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete