Quote:
I already have the main site up and running, this module requires that i change the first site. I would rather just call the user table from the first sites database and then the second site can have its own modules seperate from the first. Probably not possible.
Well, that's exactly what the system I described to nekro does. And to correct him: it doesn't require MySQL 5... it uses the MySQL MERGE storage engine which has been introduced in MySQL 3.23.25.
Here's how to use it:
- Install the 1st site, using the DB prefix "site1"
- Install the 2nd site, using the DB prefix "site2"
- Use phpMyAdmin to execute the following queries
DROP TABLE site2_groups;
CREATE TABLE site2_groups (
groupid smallint(5) unsigned NOT NULL auto_increment,
name varchar(50) NOT NULL default '',
description text NOT NULL,
group_type varchar(10) NOT NULL default '',
KEY groupid (groupid),
KEY group_type (group_type)
) TYPE=MERGE UNION=(site1_groups) INSERT_METHOD=FIRST;
DROP TABLE site2_groups_users_link;
CREATE TABLE site2_groups_users_link (
linkid mediumint(8) unsigned NOT NULL auto_increment,
groupid smallint(5) unsigned NOT NULL default '0',
uid mediumint(8) unsigned NOT NULL default '0',
KEY linkid (linkid),
KEY groupid_uid (groupid,uid)
) TYPE=MERGE UNION=(site1_groups_users_link) INSERT_METHOD=FIRST;
DROP TABLE site2_users;
CREATE TABLE site2_users (
uid mediumint(8) unsigned NOT NULL auto_increment,
name varchar(60) NOT NULL default '',
uname varchar(25) NOT NULL default '',
email varchar(60) NOT NULL default '',
url varchar(100) NOT NULL default '',
user_avatar varchar(30) NOT NULL default 'blank.gif',
user_regdate int(10) unsigned NOT NULL default '0',
user_icq varchar(15) NOT NULL default '',
user_from varchar(100) NOT NULL default '',
user_sig tinytext NOT NULL,
user_viewemail tinyint(1) unsigned NOT NULL default '0',
actkey varchar(8) NOT NULL default '',
user_aim varchar(18) NOT NULL default '',
user_yim varchar(25) NOT NULL default '',
user_msnm varchar(100) NOT NULL default '',
pass varchar(32) NOT NULL default '',
posts mediumint(8) unsigned NOT NULL default '0',
attachsig tinyint(1) unsigned NOT NULL default '0',
rank smallint(5) unsigned NOT NULL default '0',
level tinyint(3) unsigned NOT NULL default '1',
theme varchar(100) NOT NULL default '',
timezone_offset float(3,1) NOT NULL default '0.0',
last_login int(10) unsigned NOT NULL default '0',
umode varchar(10) NOT NULL default '',
uorder tinyint(1) unsigned NOT NULL default '0',
notify_method tinyint(1) NOT NULL default '1',
notify_mode tinyint(1) NOT NULL default '0',
user_occ varchar(100) NOT NULL default '',
bio tinytext NOT NULL,
user_intrest varchar(150) NOT NULL default '',
user_mailok tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (uid),
KEY uname (uname),
KEY email (email),
KEY uiduname (uid,uname),
KEY unamepass (uname,pass)
) TYPE=MERGE UNION=(site1_users) INSERT_METHOD=FIRST;
(if you didn't use site1/site2 when installing, edit the queries)
This will delete the site2 users/groups tables, and create "virtual" ones that point to the equivalent site1 tables. So, in the facts there is only 1 list of users/groups that is used by both sites.
There's no need to hack anything, and if the users table format is modified in a future version, there will be no problem to upgrade... just ensure you upgrade "site1" first, and the subsites after.
PS: I just wrote the queries while posting this, so make a backup of these 3 tables before trying, there might be a typo in the SQL... you never now.
PS2: If you have control over your MySQL permissions, you can even change the queries to have the site2 tables point to tables in another database, by replacing "site1_xxx" by "thesite1db.site1_xxx". Just ensure the MySQL user used by subsites have access to the users/groups/users_groups_link tables of the main site database.
PS3: If you don't understand PS2, forget about it... Just install all site using the same database/user/pwd, and use different prefixes.
Any intelligent fool can make things bigger, and more complex. It takes a touch of genius, a lot of courage, to move in the opposite direction.
Two things are infinite: the universe and human stupidity; and I'm not sure about the 1st one (A.Einstein)