Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 09:06:23 AM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155535 Posts in 21713 Topics by 7737 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: access different database - multi sites  (Read 415 times)
Availor

Offline Offline

Posts: 225



« on: May 10, 2010, 10:28:00 PM »

Hello again...

Ok, this is a database question: My php skills are at very basic level, so I will try to use whatever is at my disposal:

Let's say you want to make two installations of two different baker systems (1 for games and 1 for videos for example).

I install one database and one user for them both with the exception of table perfix (let's say wb1_table and wb2_table).

until now everything should work perfectly fine... two sites share the same user and same tables.

Now what I want to do is to show, lets say, the news of site 2 on site 1.
Code:
$mod_query = $database->query("SELECT title, link, published_when FROM ".TABLE_PREFIX.

Now... how do I tell it to select it from a different table (wb2_table) instead of the current (wb1_table)?

The main idea of this whole thing is to create a portal from many sites that will share identical design (I assume no one tried that before, maybe it would be a good idea to try and do so...) The main site should hold the latest info of his child sites.

An example:

I have www.mysite.com which holds the latest news and pictures from www.mysite.com/movies and www.mysite.com/games and www.mysite.com/food - which are 4 totally different sites.

Hope I'm in the right direction...
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2859



WWW
« Reply #1 on: May 11, 2010, 07:28:47 AM »

$mod_query = $database->query("SELECT title, link, published_when FROM ".TABLE_PREFIX.

Change the TABLE_PREFIX to fetch the correct tables

Code:
// Query posts (from another WB instance)
$query_posts_site1 = $database->query("SELECT * FROM "wb_1mod_news_posts
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
ORDER BY position DESC".$limit_sql);

and for another wb site:
Code:
// Query posts (from another WB instance)
$query_posts_site2 = $database->query("SELECT * FROM "wb_2mod_news_posts
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
ORDER BY position DESC".$limit_sql);

To know how the tables are called you could use phpmyadmin for exampl eto see the tables.

Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Availor

Offline Offline

Posts: 225



« Reply #2 on: May 11, 2010, 07:45:24 AM »

Thanks a lot I will try that  smiley
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!