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

R. van Twisk typo3 at rvt.dds.nl
Thu Nov 30 16:08:37 CET 2006


Toke Herkild wrote:
> 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
>   
No you cannot do that wit dBAL and make joins between two different 
databases.

since dbal works transparently across different database (Postgresql, 
Oracle, mysql) systems it is impossible to do such query (
I know it is possible on some database system, mysql it is possible but 
we need to think out site of the scope of mysql here with dBAL).

dbal will look at the tabel field and knows what DB the table is stored on.
When dBAL cannot figure it out he will simply try the default.

Ries


>  
>
> -----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
> _______________________________________________
>   

-- 
Ries van Twisk
Freelance Typo3 Developer
=== Private:
email: ries at vantwisk.nl
web:   http://www.rvantwisk.nl/freelance-typo3.html
skype: callto://r.vantwisk




More information about the TYPO3-english mailing list