vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Selecting different DBs (https://vborg.vbsupport.ru/showthread.php?t=197665)

ptmuldoon 11-30-2008 01:28 PM

Selecting different DBs
 
I've created two new tables that I've added into my vbulletin database.

But can someone possibly explain how you access and query other (non-vb) databases, to run queries, and then be able to add the results of those queries into your vbulletin database?

I done the below, but I'm not sure how to return back to the vbulletin database.
PHP Code:

if(!empty($dbname) && !empty($tname))
{
    
//Submitted Valid data, need to check if DataBase and Table exists
    
$checkdb mysql_select_db($dbname);
    if(!
$checkdb)
    {
        
$error 'Error!!  That Database does not exist. <br/><br/>Please go back and input a correct database and table name.';
        
print_cp_message($error);
    } else {
        
//Database Exists, Check to see The Table Exists..TO DO
        
           //Ok, Its a new item Database and Table, so add it
        
$query $db->query_read("INSERT INTO " TABLE_PREFIX "multi_db_add (db_name, table_name) VALUES ('{$dbname}', '{$tname}') "); 
        
print_cp_message('Database and Table added Successfully''multiuser.php?do=modify',1);
    }



ptmuldoon 12-01-2008 07:43 PM

Can anyone maybe give a hand?

I'm reading all I can on the vbulletin database class, but I can't seem to figure out how to re-access the my vbulletin database after using mysql_select_db() to work with a non-vb database.

Dismounted 12-02-2008 02:13 AM

You can use this "query style" to access a different database (as long as the user has permissions to do so). This does not need the mysql_select_db() function.
[sql]SELECT *
FROM database1.table1[/sql]


All times are GMT. The time now is 05:51 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.01073 seconds
  • Memory Usage 1,719KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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