Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-07 23:21:39

Erdanese
New Member
Registered: 2004-05-26
Posts: 4

allow 2 different TXP installations to access the same MySQL database?

In other words, we have several different sites sitting together in the same directory (they are in sub-directories) on the same server. Each is of course a separate TXP installation. We would however like to be able to bring data (a site “A” category, that is) into a site “B” div without having to copy it over by hand – directly, that is. We can imagine complicated scripts governing periodic “cron” dumps and imports and so on, but would rather not get involved in that.

To say it all a little differently, we want some, but not all, of the site “A” articles to be “seen” by, and so appear on, site “B” as well. We are working on the assumption that the site “B” tools in TXP that consult the “B” MySQL database to extract articles – which data is then passed to the “B” formatting and display functions – could in some circumstances be given the path and password to the “A” database to extract appropriate data from there and return it to the “B” formatting and display chain.

This would allow us – to say it all a third way – to have for instance a general science news site on “A” automatically supply “medicine” category articles to a bio-science site on the “B” installation.

In theory, avoiding mindless copying is the sort of thing computers are good at… A cursory search shows nothing here on the forums though, but that may be because we haven’t a clue as to how to phrase the query.

Can anybody point us in a useful direction?

Offline

#2 2005-12-08 00:00:19

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: allow 2 different TXP installations to access the same MySQL database?

The only thing I can think of that might help you is this: <a href=“http://textpattern.net/wiki/index.php?title=Importing_Article_Content_from_One_Textpattern_Install_to_Another”>Textbook: Importing Article Content from One Textpattern Install to Another</a>. And even that, it looks like, is not what you’re really looking for.

Textpattern isn’t really set up to access data from other installs, even if that information is in the same database. Not that this does you much good now (but might one day help someone doing a search), but this sort of thing is really better suited to using a single installations, with “Content A” and “Content B” each using different sections.

Maybe someone else here has experience dealing with this sort of thing, but I can’t really think of an easy way to do what you’re attempting.

Offline

#3 2005-12-08 00:08:48

Erdanese
New Member
Registered: 2004-05-26
Posts: 4

Re: allow 2 different TXP installations to access the same MySQL database?

Thank you. We did take a look at the Textbook article you suggest. I suspect that in the end ours is more a MySQL question than a strictly TXP one – or some of both really… Unfortunately, either way we don’t know enough about it! The functionality we’re trying to get at would seem to offer a lot of interesting possibilities though.

Cheers

Offline

#4 2005-12-08 10:53:12

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: allow 2 different TXP installations to access the same MySQL database?

Hindsight is always 100% isn’t it? If I were setting this up from the start I would have used a single TXP install and “separated” the different “sites” using sections. With TXP you can assign different CSS to different “sections” so that they can look completely different, almost as though you had moved to a different site, the only common factor being that they would have similar URLs. Having a single install like this would mean that you could call articles from one section or site into another without much problem.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#5 2005-12-08 14:25:27

Erdanese
New Member
Registered: 2004-05-26
Posts: 4

Re: allow 2 different TXP installations to access the same MySQL database?

Well Stuart, it wouldn’t necessarily be too late to do that. The sites themselves are quite simple. A couple of them though are sitting on top of what have become surprisingly large data bases that we would now like to “mine” more effectively. “Similar URLs” would not do, because the sites have radically different identities, but I suppose, depending on how these names are composed, it might be possible to use DNS masking to point the old site names at the new sections. I expect that all this would raise the very devil with Google advertising (which does bring in something), the various counters and the search functions though. Oh well. I guess, as you implicitly suggest, we’ll leave that to another time when we start over at the top on something else.

Since I know you know, I gather we can now abandon the thought of using built-in TXP functions to accomplish the job. Supposing though we just forget about TXP for the moment. Is it reasonable to imagine developing a little bit of code that “simply” executes a periodic MySQL query whenever it is invoked, goes to see whether anything new matches the query in the “A” database and, if there is, extracts it and writes it to the “B” database? It seems to me that would do the trick – though I probably am by definition now on the wrong forum to discuss it…

Offline

#6 2005-12-08 18:07:31

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: allow 2 different TXP installations to access the same MySQL database?

I’m not an SQL expert so I can’t help you on that but I suspect that if it were possible it could well be quite complex. As for being in the wrong forum we are talking about TXP databases so I think not. :) There may be people more knowledgeable in SQL that could help you with this here.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#7 2005-12-08 18:48:42

KurtRaschke
Plugin Author
Registered: 2004-05-16
Posts: 275

Re: allow 2 different TXP installations to access the same MySQL database?

Since I know you know, I gather we can now abandon the thought of using built-in TXP functions to accomplish the job. Supposing though we just forget about TXP for the moment. Is it reasonable to imagine developing a little bit of code that “simply” executes a periodic MySQL query whenever it is invoked, goes to see whether anything new matches the query in the “A” database and, if there is, extracts it and writes it to the “B” database? It seems to me that would do the trick – though I probably am by definition now on the wrong forum to discuss it…

I am not entirely sure that it’s necessary to completely abandon the built-in TXP functions. It’s certainly possible to use PHP to connect to the “B” database from within the “A” Textpattern instance and pull out an article and format it for display. Of course, you won’t be able to use the functions in <code>txplib_db.php</code> to do this, since <code>txplib_db.php</code> will want to talk to the “A” Textpattern instance’s database.

But you can certainly just use the raw <code>mysql_query()</code> to pull things out of a database.

And it’d be much better to do it on-the-fly then have, for example, a cron job to manually synchronize the databases.

-Kurt

Last edited by KurtRaschke (2005-12-08 18:49:30)


kurt@kurtraschke.com

Offline

Board footer

Powered by FluxBB