[TYPO3] Seeking advice on how to use two databases...

Toke Herkild th at concare.net
Wed Nov 29 15:44:13 CET 2006


Hi all,

Could be done as :
Select p.*, c.id, c.name from db1.person p, db2.company c where p.worksfor=c.id;

Regards,
Toke
 

-----Oprindelig meddelelse-----
Fra: typo3-english-bounces at lists.netfielders.de [mailto:typo3-english-bounces at lists.netfielders.de] På vegne af Tim Riemenschneider
Sendt: 29. november 2006 14:30
Til: typo3-english at lists.netfielders.de
Emne: Re: [TYPO3] Seeking advice on how to use two databases...



By using the ext. dbal this should be possible.
While TYPO3 only supports one database, this means, that everything is in one "logical" DB. You can distribute the content into several "real" 
DBs on a per-table basis.
See: 
http://typo3.org/documentation/document-library/extension-manuals/dbal/current/view/1/1/

The only conditions is, that you can't use JOIN across DB-borders, which is easily understandable.
(Example:
Tables:
Person with Fields: id, name, worksFor
Company with: id: name

when using dbal (and different databases) with these, this does not work:
SELECT person.name, company.name FROM person,company WHERE person.worksFor == company.id and in PHP: echo "Person ".$result['person.name']." works for ".$result['company.name'];

since neither database knows of the other. (To which of the two databases should this query be send??)

As a workaround you can split this into two DB-queries, each can be send to the right DB:
q1: SELECT name,worksFor from person
q2: SELECT name from company where id==$q1[worksFor] echo "Person ".$q1['name']." works for ".$q2['name'];

you get the idea.)

(Disclaimer: I haven't used dbal myself.... so don't blame me, if this doesn't work.....)

cu
Tim
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.netfielders.de
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english


More information about the TYPO3-english mailing list