vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   database linking and table linking (https://vborg.vbsupport.ru/showthread.php?t=75292)

patriotcow 01-28-2005 10:57 AM

database linking and table linking
 
Ok I have this task that I want to do for 2 of my forums and maybe more in the future.
I would like to link tables from databases that are in seperate databases from each other.

E.g:

I have a database named vbulletin1 and in vbulletin1 there is a table called vb_users. Then I have a database named vbulletin2 and there is a table called vb_users. How would I link the 2 vb_users together so that on both forums the users are updated on both if you get me?

Thanks

Dean C 01-28-2005 11:05 AM

This has been asked several times and as it stands it's a pretty major undertaking :) There's no easy way to do it.

patriotcow 01-28-2005 11:19 AM

The best method would be in phpmyadmin?

Andreas 01-28-2005 11:49 AM

You can't.
Having x installations share a common user base requires almost all vBulletin PHP files to be modified.

Marco van Herwaarden 01-28-2005 12:12 PM

Just think of all the duplicate userid's for example, then you will understand this is not something that can easily be done

Dean C 01-28-2005 01:01 PM

It could be done via the database class if vBulletin used aliases on all table names it would be possible to do it internally (in theory) with a few reg exps in the db class :)

Dean C 01-28-2005 01:56 PM

Something interesting to think about:
PHP Code:

    $dbprefix 'newdb';
    
$string "SELECT * FROM user AS user WHERE userid='moo'";
    
$pattern '/(.*)FROM[\s\n\r]+([A-Za-z]+)[\s\n\r]+AS[\s\n\r]+(\\2)(.*)/';
    if(
preg_match($pattern$string$array))
    {    
        
print_r($array);
        
$nstring preg_replace($pattern"$1 FROM $dbprefix.$2 AS $3 $4"$string);
        echo 
'<br />' $nstring;
    } 

Now thinking about it, if we did the same for INSERT, UPDATE, REPLACE INTO and DELETE we could be on to something as it seems the devs have introduced aliases to all tables since the first gold release :)

patriotcow 01-28-2005 09:07 PM

Ahh that looks like somthing :nervous: Trouble is I am no expert on hacks :disappointed:

Dean C 01-28-2005 09:14 PM

I did it earlier, it works. But usergroup and forum permissions are big issues which require too much code editing to even think about :)

patriotcow 01-28-2005 09:40 PM

You should tell me how so I can work on it more I might pay somone...but wouldn't mind a bit of knoledge on what youve done so far :nervous:


All times are GMT. The time now is 09:24 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.01165 seconds
  • Memory Usage 1,727KB
  • 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
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete