vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   SQL Query in profile tab (https://vborg.vbsupport.ru/showthread.php?t=200491)

TriggerHappy123 01-02-2009 11:11 PM

SQL Query in profile tab
 
I made a plugin to add a new tab to a users profile, how would i make the data thats shown in the tab be from an executed MySQL Query?

PHP Code:

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
    var 
$template_name 'memberinfo_block_mymodification';

    function 
confirm_empty_wrap()
    {
        return 
false;
    }

    function 
confirm_display()
    {
        return (
$this->block_data['mymodification'] != '');
    }

    function 
prepare_output($id ''$options = array())
    {
        
$this->block_data['mymodification'] = 'QUERY HERE'// what would i do here
    
}



Dismounted 01-03-2009 03:30 AM

The DB object can be called inside the class using $this->registry->db.

TriggerHappy123 01-03-2009 04:23 AM

Sorry i'm a php noob. A simple example using my code?

Dismounted 01-03-2009 05:25 AM

If you do not know PHP - I doubt any examples are going to help, dealing with SQL and the like is a bit further down the track. I would suggest you learn PHP as best you can before dealing with vBulletin.

Lynne 01-03-2009 04:34 PM

You would put the query inside the function prepare_output. You would not put it in "$this->block_data['mymodification']" as that should contain the html to output. You would do the query as Hanson suggestion, then get the results and put it in the block_data.

TriggerHappy123 01-04-2009 09:39 PM

Quote:

If you do not know PHP
I never said that, im a noob in php. I can write scripts and i have dealt with using databases before. I just need an example on how to do it with vbulletin, and it's weird template system.

Lynne 01-04-2009 09:47 PM

You would do something like this:
PHP Code:

    function prepare_output($id ''$options = array()) 
    { 
$subres $this->registry->db->query_read("SELECT STATEMENT HERE");
$result $this->registry->db->fetch_array($subres);

        
$this->block_data['mymodification'] = 'HTML OUTPUT'
    } 


TriggerHappy123 01-04-2009 10:04 PM

Thanks, will try it out. I would +rep you only vb.org doesn't have rep :mad:


All times are GMT. The time now is 01:06 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.01088 seconds
  • Memory Usage 1,733KB
  • 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
  • (2)bbcode_php_printable
  • (1)bbcode_quote_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